summaryrefslogtreecommitdiff
path: root/srv/cmd/userid-calc-cli/main.go
blob: c86ae5da5420b202a286e59eae8ab840e24c22b6 (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
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))
}