52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package passwd
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPasswd256(t *testing.T) {
|
|
password := []byte("lbmanager")
|
|
wrongPasswd := []byte("qwerty")
|
|
|
|
hash := MakeSHA256Hash(password)
|
|
fmt.Printf("%s\n", hash)
|
|
{
|
|
match := PasswordMatchCompat(password, hash)
|
|
require.Equal(t, true, match)
|
|
}
|
|
{
|
|
match := PasswordMatchCompat(wrongPasswd, hash)
|
|
require.NotEqual(t, true, match)
|
|
}
|
|
}
|
|
|
|
func xxxTestPasswd256X(t *testing.T) {
|
|
password := []byte("1234567890")
|
|
|
|
hash := "sha256pwd:1362271d756aa59e78a53c2ea65433b0:13cfe8d667b92ca3b050bb631ed76f7af218f8f23075ee0cabddb71103b39d93"
|
|
fmt.Printf("%s\n", hash)
|
|
{
|
|
match := PasswordMatch(password, hash)
|
|
require.Equal(t, true, match)
|
|
}
|
|
}
|
|
|
|
func xxxTestPasswd512(t *testing.T) {
|
|
password := []byte("123456781")
|
|
wrongPasswd := []byte("qwerty")
|
|
|
|
hash := MakeSHA512Hash(password)
|
|
fmt.Printf("%s\n", hash)
|
|
{
|
|
match := PasswordMatchCompat(password, hash)
|
|
require.Equal(t, true, match)
|
|
}
|
|
{
|
|
match := PasswordMatchCompat(wrongPasswd, hash)
|
|
require.NotEqual(t, true, match)
|
|
}
|
|
}
|