2023-05-11 01:13:32 +02:00
|
|
|
package genkey
|
2022-05-02 17:19:37 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"encoding/base64"
|
|
|
|
"fmt"
|
2023-05-11 01:13:32 +02:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
2022-05-02 17:19:37 +02:00
|
|
|
)
|
|
|
|
|
2023-05-11 01:13:32 +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)
|
2023-05-11 01:13:32 +02:00
|
|
|
return nil
|
2022-05-02 17:19:37 +02:00
|
|
|
}
|