0
internal/cryptography/aes.go
Normal file
0
internal/cryptography/aes.go
Normal file
22
internal/cryptography/bcrypt.go
Normal file
22
internal/cryptography/bcrypt.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package cryptography
|
||||||
|
|
||||||
|
import "golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
|
func BcryptHash(input string) (string, error) {
|
||||||
|
hash, err := bcrypt.GenerateFromPassword(
|
||||||
|
[]byte(input),
|
||||||
|
bcrypt.DefaultCost,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(hash), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func BcryptVerify(input string, hashed string) bool {
|
||||||
|
err := bcrypt.CompareHashAndPassword(
|
||||||
|
[]byte(hashed),
|
||||||
|
[]byte(input),
|
||||||
|
)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user