From 9ee92da5e3d52fe11415193a9391eee3ad541c72 Mon Sep 17 00:00:00 2001 From: maride Date: Sat, 8 Sep 2018 01:29:22 +0200 Subject: Avoid collision by adding the hashed username to networks --- src/credentials.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/credentials.go') 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 -- cgit 1.4.1