2024-11-18 15:23:13 +00:00
|
|
|
// Copyright 2024 Patial Tech. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2024-11-15 16:12:15 +00:00
|
|
|
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 !ComparePasswordHash(pwd, string(hash), string(salt)) {
|
|
|
|
t.Error("supposed to match")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|