2020-10-15 19:06:25 +00:00
|
|
|
package hash
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2021-07-26 16:59:33 +00:00
|
|
|
func Test_UnitSCrypt_VerifyHash(t *testing.T) {
|
2021-07-13 17:44:11 +00:00
|
|
|
type args struct {
|
|
|
|
secretKey string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Basic Hash Test",
|
|
|
|
args: args{
|
|
|
|
secretKey: "hello world",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Long Hash Test",
|
|
|
|
args: args{
|
|
|
|
secretKey: strings.Repeat("A", 720),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
hasher := NewSCrypt()
|
|
|
|
hash, _ := hasher.CreateHash(tt.args.secretKey)
|
|
|
|
if err := hasher.VerifyHash(hash, tt.args.secretKey); (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("SCrypt.VerifyHash() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2020-10-15 19:06:25 +00:00
|
|
|
}
|