2025-06-16 22:19:00 +05:30
|
|
|
// Copyright 2024 Patial Tech (Ankit Patial).
|
2025-06-16 22:26:47 +05:30
|
|
|
//
|
|
|
|
// This file is part of code.patial.tech/go/appcore, which is MIT licensed.
|
|
|
|
// See http://opensource.org/licenses/MIT
|
2025-06-16 22:19:00 +05:30
|
|
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|