feat(user): add encryption algorithm and salt fields to User model for migrate

This commit is contained in:
Chang lue Tsen
2025-10-09 13:33:03 -04:00
parent de4386ff68
commit 8562734fde
14 changed files with 20 additions and 7 deletions
+1 -3
View File
@@ -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)
+1 -1
View File
@@ -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)
}