You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
340 B
14 lines
340 B
1 year ago
|
package util
|
||
|
|
||
|
import "golang.org/x/crypto/bcrypt"
|
||
|
|
||
|
func PasswordHash(password string) (string, error) {
|
||
|
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
|
||
|
return string(bytes), err
|
||
|
}
|
||
|
|
||
|
func PasswordVerify(password, hash string) bool {
|
||
|
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||
|
return err == nil
|
||
|
}
|