summary refs log tree commit diff stats
path: root/hibp/hash.go
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-16 17:29:15 +0530
committerAndinus <andinus@inventati.org>2020-03-16 17:29:15 +0530
commitb75359931e3c5baaded6d0addb6d28f750dcd518 (patch)
treed21197d18dad2bc58d081263c0192abc7110edaa /hibp/hash.go
parent553079dc017a44164cd04d4c067c061003e1684f (diff)
downloadorion-b75359931e3c5baaded6d0addb6d28f750dcd518.tar.gz
Add initial version of orion v0.1.0
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)))
+}