basic common app packages
This commit is contained in:
27
crypto/argon2_test.go
Normal file
27
crypto/argon2_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2024 Patial Tech (Ankit Patial).
|
||||
// All rights reserved.
|
||||
|
||||
package crypto
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPasswordHash(t *testing.T) {
|
||||
pwd := "MY Bingo pwd"
|
||||
hash, salt, err := PasswordHash(pwd)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if hash == "" || salt == "" {
|
||||
t.Error("either hash or password is empty")
|
||||
return
|
||||
}
|
||||
|
||||
if ok, err := ComparePasswordHash(pwd, string(hash), string(salt)); err != nil {
|
||||
t.Error(err)
|
||||
} else if !ok {
|
||||
t.Error("supposed to match")
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user