1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

密码评估,密码加密

This commit is contained in:
2022-06-22 11:23:47 +08:00
parent 2fd5c8e662
commit dce7e8cb9f
3 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,23 @@
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)))
}
}