Public Access
Rename the module, CLI command name, and all references from keystone/basalt to draft, and fix the stale build/README content found along the way.
38 lines
769 B
Go
38 lines
769 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
newCmd.AddCommand(keyCmd)
|
|
}
|
|
|
|
var size int
|
|
var defaultSize = 32
|
|
|
|
var keyCmd = &cobra.Command{
|
|
Use: "key [size]",
|
|
Short: "Generate a new cryptographic key",
|
|
Long: `Generate a new cryptographic key for use in Draft projects.`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
var keyLength int
|
|
if cmd.Flags().Lookup("size").Changed {
|
|
keyLength = size
|
|
} else {
|
|
keyLength = defaultSize
|
|
}
|
|
|
|
if keyLength <= 32 {
|
|
fmt.Println("Warning: It is recommended to use a key size greater than 32 for better security.")
|
|
fmt.Println("Generating a key of default size:", defaultSize)
|
|
keyLength = defaultSize
|
|
}
|
|
|
|
key := randomString(keyLength)
|
|
println("Generated Key:", key)
|
|
},
|
|
}
|