feat: keep backward compatibility in GetHashedPassword()

This commit is contained in:
Yang Luo
2025-07-21 19:32:59 +08:00
parent 65ab36f073
commit e05fbec739
3 changed files with 24 additions and 0 deletions

View File

@@ -41,9 +41,17 @@ func (cm *Sha512SaltCredManager) GetHashedPassword(password string, salt string)
if salt == "" {
return getSha512HexDigest(password)
}
return getSha512HexDigest(getSha512HexDigest(password) + salt)
}
func (cm *Sha512SaltCredManager) IsPasswordCorrect(plainPwd string, hashedPwd string, salt string) bool {
// For backward-compatibility
if salt == "" {
if hashedPwd == cm.GetHashedPassword(getSha512HexDigest(plainPwd), salt) {
return true
}
}
return hashedPwd == cm.GetHashedPassword(plainPwd, salt)
}