summaryrefslogtreecommitdiff
path: root/srv/cmd/userid-calc-cli/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'srv/cmd/userid-calc-cli/main.go')
-rw-r--r--srv/cmd/userid-calc-cli/main.go27
1 files changed, 27 insertions, 0 deletions
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))
+}