mediocre-blog/srv/cmd/userid-calc-cli/main.go
2021-08-18 18:13:44 -06:00

28 lines
500 B
Go

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))
}