2023-05-10 16:13:32 -07:00
|
|
|
package genkey
|
2022-05-02 08:19:37 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"encoding/base64"
|
|
|
|
"fmt"
|
2023-05-10 16:13:32 -07:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
2022-05-02 08:19:37 -07:00
|
|
|
)
|
|
|
|
|
2023-05-10 16:13:32 -07: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 08:19:37 -07:00
|
|
|
b := make([]byte, 64)
|
|
|
|
|
|
|
|
_, err := rand.Read(b)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s := base64.URLEncoding.EncodeToString(b)
|
|
|
|
|
|
|
|
fmt.Println(s)
|
2023-05-10 16:13:32 -07:00
|
|
|
return nil
|
2022-05-02 08:19:37 -07:00
|
|
|
}
|