feat(user): add encryption algorithm and salt fields to User model for migrate
This commit is contained in:
@@ -40,15 +40,13 @@ func MultiPasswordVerify(algo, salt, password, hash string) bool {
|
||||
case "md5":
|
||||
sum := md5.Sum([]byte(password))
|
||||
return hex.EncodeToString(sum[:]) == hash
|
||||
|
||||
case "sha256":
|
||||
sum := sha256.Sum256([]byte(password))
|
||||
return hex.EncodeToString(sum[:]) == hash
|
||||
|
||||
case "md5salt":
|
||||
sum := md5.Sum([]byte(password + salt))
|
||||
return hex.EncodeToString(sum[:]) == hash
|
||||
case "default":
|
||||
case "default": // PPanel's default algorithm
|
||||
return VerifyPassWord(password, hash)
|
||||
case "bcrypt":
|
||||
// Bcrypt (corresponding to PHP's password_hash/password_verify)
|
||||
|
||||
@@ -10,6 +10,6 @@ func TestEncodePassWord(t *testing.T) {
|
||||
|
||||
func TestMultiPasswordVerify(t *testing.T) {
|
||||
pwd := "$2y$10$WFO17pdtohfeBILjEChoGeVxpDG.u9kVCKhjDAeEeNmCjIlj3tDRy"
|
||||
status := MultiPasswordVerify("", "", "admin", pwd)
|
||||
status := MultiPasswordVerify("bcrypt", "", "admin1", pwd)
|
||||
t.Logf("MultiPasswordVerify: %v", status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user