From ae02f537f777f6147d57b24d5684a96408621520 Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Sun, 11 Oct 2015 21:39:42 -0400 Subject: [PATCH] Add linx-genkey --- linx-genkey/linx-genkey.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 linx-genkey/linx-genkey.go diff --git a/linx-genkey/linx-genkey.go b/linx-genkey/linx-genkey.go new file mode 100644 index 0000000..95389da --- /dev/null +++ b/linx-genkey/linx-genkey.go @@ -0,0 +1,33 @@ +package main + +import ( + "bufio" + "encoding/base64" + "fmt" + "os" + + "golang.org/x/crypto/scrypt" +) + +const ( + authPrefix = "Linx " + scryptSalt = "linx-server" + scryptN = 16384 + scryptr = 8 + scryptp = 1 + scryptKeyLen = 32 +) + +func main() { + fmt.Printf("Enter key to hash: ") + + scanner := bufio.NewScanner(os.Stdin) + scanner.Scan() + + checkKey, err := scrypt.Key([]byte(scanner.Text()), []byte(scryptSalt), scryptN, scryptr, scryptp, scryptKeyLen) + if err != nil { + return + } + + fmt.Println(base64.StdEncoding.EncodeToString(checkKey)) +}