Exemplo n.º 1
0
Arquivo: user.go Projeto: Ganben/blog
// encode password string, return encoded string and salt
func EncodePassword(pwd string) (string, string) {
	tmp := time.Now().Format(time.RFC3339)
	salt := utils.Md5String(tmp)[8:24]
	return utils.Sha256String(pwd + salt), salt
}
Exemplo n.º 2
0
Arquivo: user.go Projeto: Ganben/blog
// check password string
func (u *User) CheckPassword(str string) bool {
	pwd := utils.Sha256String(str + u.Salt)
	return pwd == u.Password
}