about summary refs log tree commit diff
path: root/src/credentials.go
blob: 03dd34e4616a76ccb0222a157a9637f39c6c8c0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main

import (
	"crypto/sha512"
	"flag"
	"fmt"
)

var (
	username* string
	accessCode* string
	compiledHash string
)

func registerCredentialsFlags() {
	username = flag.String("username", "Player 1", "Username")
	accessCode = flag.String("accessCode", "AllYourCodesAreBelongToUs", "Access code for the user")
}


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
}