WIP: Something is going on

This commit is contained in:
2024-03-21 18:39:32 +01:00
parent 58c1b91916
commit 782e762019
7 changed files with 98 additions and 102 deletions

View File

@ -8,7 +8,6 @@ func HashPassword(password string, cost int) (string, error) {
}
func CheckPasswordHash(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}

View File

@ -8,14 +8,14 @@ import (
)
func TestHashValid(t *testing.T) {
password := "qwertyu9"
hpass, err := hash.HashPassword(password, 10)
assert.NoError(t, err)
assert.True(t, hash.CheckPasswordHash(password, hpass))
password := "qwertyu9"
hpass, err := hash.HashPassword(password, 10)
assert.NoError(t, err)
assert.True(t, hash.CheckPasswordHash(password, hpass))
}
func TestHashInvalid(t *testing.T) {
password := "qwertyu9"
invhash := "qwertyu9"
assert.False(t, hash.CheckPasswordHash(password, invhash))
password := "qwertyu9"
invhash := "qwertyu9"
assert.False(t, hash.CheckPasswordHash(password, invhash))
}