mirror of
https://github.com/thomiceli/opengist.git
synced 2025-05-14 00:02:10 +02:00
Better password hashes error handling (#132)
This commit is contained in:
parent
7059d5c834
commit
b1acea9f1c
@ -265,8 +265,16 @@ func (a Argon2ID) hash(plain string) (string, error) {
|
||||
}
|
||||
|
||||
func (a Argon2ID) verify(plain, hash string) (bool, error) {
|
||||
if hash == "" {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
hashParts := strings.Split(hash, "$")
|
||||
|
||||
if len(hashParts) != 6 {
|
||||
return false, errors.New("invalid hash")
|
||||
}
|
||||
|
||||
_, err := fmt.Sscanf(hashParts[3], "m=%d,t=%d,p=%d", &a.memory, &a.time, &a.threads)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user