diff --git a/internal/cryptography/aes.go b/internal/cryptography/aes.go new file mode 100644 index 0000000..e69de29 diff --git a/internal/cryptography/bcrypt.go b/internal/cryptography/bcrypt.go new file mode 100644 index 0000000..50420ce --- /dev/null +++ b/internal/cryptography/bcrypt.go @@ -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 +}