about summary refs log tree commit diff
path: root/src/credentials.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/credentials.go')
-rw-r--r--src/credentials.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/credentials.go b/src/credentials.go
index 7bbcf19..03dd34e 100644
--- a/src/credentials.go
+++ b/src/credentials.go
@@ -1,10 +1,15 @@
 package main
 
-import "flag"
+import (
+	"crypto/sha512"
+	"flag"
+	"fmt"
+)
 
 var (
 	username* string
 	accessCode* string
+	compiledHash string
 )
 
 func registerCredentialsFlags() {
@@ -15,4 +20,14 @@ func registerCredentialsFlags() {
 
 func verifyCredentials(un string, ac string) (bool) {
 	return *username == un && *accessCode == ac
+}
+
+func getUsernameHash() (string) {
+	if compiledHash == "" {
+		hasher := sha512.New()
+		hasher.Write([]byte(*username))
+		compiledHash = fmt.Sprintf("%x", hasher.Sum(nil))
+	}
+
+	return compiledHash
 }
\ No newline at end of file