重构
This commit is contained in:
1 parent
38d3b7450e
commit
96de169777
45 files changed
+881
-676
No files matched your search
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import "golang.org/x/crypto/bcrypt"
|
||||
|
||||
// Encrypt 加密明文密码
|
||||
func Encrypt(password string) (string, error) {
|
||||
hashedBytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
return string(hashedBytes), err
|
||||
}
|
||||
|
||||
// Compare 密文校验
|
||||
func Compare(hashedPassword, password string) error {
|
||||
return bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
|
||||
}
|
||||
Reference in new issue
Block a user