Example #1
0
func TestValidPassword(t *testing.T) {
	pass := "******"
	hash := "{SSHA256}czO44OTV17PcF1cRxWrLZLy9xHd7CWyVYplr1rOhuMlx/7IK"

	if res, err := ssha256.Validate(pass, hash); err != nil || res != true {
		t.Errorf("Valid password fails validation: %s", err)
	}
}
Example #2
0
func TestInValidPassword(t *testing.T) {
	pass := "******"
	hash := "{SSHA256}czO44OTV17PcF1cRxWrLZLy9xHd7CWyVYplr1rOhuMlx/7IK"

	if res, err := ssha256.Validate(pass, hash); res != false {
		t.Errorf("Invalid password passes validation: %s", err)
	}
}
Example #3
0
func TestGenerate8(t *testing.T) {
	pass := "******"
	var hash string
	var err error
	var res bool

	if hash, err = ssha256.Generate(pass, 8); err != nil {
		t.Errorf("Generate password fails: %s", err)
		return
	}

	if res, err = ssha256.Validate(pass, hash); err != nil && res != false {
		t.Errorf("Generated hash can not be validated: %s", err)
	}
}