chore: upgrade dependencies and secure passwords
This commit is contained in:
12
module/ec/mall/internal/password/password.go
Normal file
12
module/ec/mall/internal/password/password.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package password
|
||||
|
||||
import "golang.org/x/crypto/bcrypt"
|
||||
|
||||
func Hash(plain string) (string, error) {
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(plain), bcrypt.DefaultCost)
|
||||
return string(hash), err
|
||||
}
|
||||
|
||||
func Verify(hash, plain string) bool {
|
||||
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(plain)) == nil
|
||||
}
|
||||
Reference in New Issue
Block a user