pronounss/scripts/genkey/main.go

30 lines
398 B
Go
Raw Normal View History

package genkey
2022-05-02 17:19:37 +02:00
import (
"crypto/rand"
"encoding/base64"
"fmt"
"github.com/urfave/cli/v2"
2022-05-02 17:19:37 +02:00
)
var Command = &cli.Command{
Name: "key",
Usage: "Generate a secure 64-byte base 64 key",
Action: run,
}
func run(c *cli.Context) error {
2022-05-02 17:19:37 +02:00
b := make([]byte, 64)
_, err := rand.Read(b)
if err != nil {
panic(err)
}
s := base64.URLEncoding.EncodeToString(b)
fmt.Println(s)
return nil
2022-05-02 17:19:37 +02:00
}