mirror of
https://github.com/1f349/tulip.git
synced 2024-11-12 23:01:33 +00:00
13 lines
329 B
Go
13 lines
329 B
Go
package password
|
|
|
|
import "golang.org/x/crypto/bcrypt"
|
|
|
|
func HashPassword(password string) (string, error) {
|
|
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
|
|
return string(bytes), err
|
|
}
|
|
|
|
func CheckPasswordHash(hash, password string) error {
|
|
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
|
}
|