diff options
author | maride <maride@darknebu.la> | 2018-09-08 01:29:22 +0200 |
---|---|---|
committer | maride <maride@darknebu.la> | 2018-09-08 01:29:22 +0200 |
commit | 9ee92da5e3d52fe11415193a9391eee3ad541c72 (patch) | |
tree | 221c8c4eb84750a843e1735c7c7cae26bb53ebea /src/credentials.go | |
parent | 0554bfa9a1ee2a7c9d3ff24749317fd9b3202ca2 (diff) |
Avoid collision by adding the hashed username to networks
Diffstat (limited to 'src/credentials.go')
-rw-r--r-- | src/credentials.go | 17 |
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 |