mirror of
https://github.com/owncast/owncast.git
synced 2024-11-28 11:09:01 +03:00
16 lines
376 B
Go
16 lines
376 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"golang.org/x/crypto/bcrypt"
|
||
|
)
|
||
|
|
||
|
func HashPassword(password string) (string, error) {
|
||
|
// 0 will use the default cost of 10 instead
|
||
|
hash, err := bcrypt.GenerateFromPassword([]byte(password), 0)
|
||
|
return string(hash), err
|
||
|
}
|
||
|
|
||
|
func ComparseHash(hash string, password string) error {
|
||
|
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||
|
}
|