From a9d8aa2591cd03fe1a9da72bab8d311e4840e8f1 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Wed, 18 Aug 2021 18:13:18 -0600 Subject: implemented basic userID generation --- srv/cmd/userid-calc-cli/main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 srv/cmd/userid-calc-cli/main.go (limited to 'srv/cmd/userid-calc-cli/main.go') diff --git a/srv/cmd/userid-calc-cli/main.go b/srv/cmd/userid-calc-cli/main.go new file mode 100644 index 0000000..c86ae5d --- /dev/null +++ b/srv/cmd/userid-calc-cli/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "encoding/json" + "flag" + "fmt" + + "github.com/mediocregopher/blog.mediocregopher.com/srv/chat" +) + +func main() { + + secret := flag.String("secret", "", "Secret to use when calculating UserIDs") + name := flag.String("name", "", "") + password := flag.String("password", "", "") + flag.Parse() + + calc := chat.NewUserIDCalculator([]byte(*secret)) + userID := calc.Calculate(*name, *password) + + b, err := json.Marshal(userID) + if err != nil { + panic(err) + } + + fmt.Println(string(b)) +} -- cgit v1.2.3