// 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 }
// check password string func (u *User) CheckPassword(str string) bool { pwd := utils.Sha256String(str + u.Salt) return pwd == u.Password }