mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-17 16:12:42 +08:00
24 lines
386 B
Go
24 lines
386 B
Go
package password
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPassword(t *testing.T) {
|
|
pwd := "123456"
|
|
|
|
h1, _ := GenerateFromPassword([]byte(pwd))
|
|
t.Log(ComparePassword(h1, []byte(pwd)))
|
|
|
|
for i := 0; i < 100; i++ {
|
|
h, err := GenerateFromPassword([]byte(pwd))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
assert.True(t, ComparePassword(h, []byte(pwd)))
|
|
}
|
|
}
|