mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-26 16:56:30 +00:00
13 lines
345 B
Go
13 lines
345 B
Go
package hasher
|
|
|
|
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(password, hash string) bool {
|
|
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
|
return err == nil
|
|
}
|