summary refs log tree commit diff stats
path: root/hibp/hash.go
diff options
context:
space:
mode:
Diffstat (limited to 'hibp/hash.go')
-rw-r--r--hibp/hash.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/hibp/hash.go b/hibp/hash.go
new file mode 100644
index 0000000..25249ed
--- /dev/null
+++ b/hibp/hash.go
@@ -0,0 +1,15 @@
+package hibp
+
+import (
+	"crypto/sha1"
+	"encoding/hex"
+	"strings"
+)
+
+// GetHsh takes a string as an input & returns SHA-1 Hash
+func GetHsh(pass string) string {
+	alg := sha1.New()
+	alg.Write([]byte(pass))
+
+	return strings.ToUpper(hex.EncodeToString(alg.Sum(nil)))
+}