mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
Better password hashes error handling (#132)
This commit is contained in:
parent
7059d5c834
commit
b1acea9f1c
1 changed files with 8 additions and 0 deletions
|
@ -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…
Reference in a new issue