mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 02:44:02 +03:00
FILE / ScuroNeko/mtg
cli/generate.go
Исходный файл и его история в репозитории.
26 lines
433 B
Go
26 lines
433 B
Go
package cli
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
|
|
"github.com/9seconds/mtg/config"
|
|
)
|
|
|
|
func Generate(secretType string) {
|
|
data := make([]byte, config.SimpleSecretLength)
|
|
if _, err := rand.Read(data); err != nil {
|
|
panic(err)
|
|
}
|
|
secret := hex.EncodeToString(data)
|
|
|
|
switch secretType {
|
|
case "simple":
|
|
PrintStdout(secret)
|
|
case "secured":
|
|
PrintStdout("dd" + secret)
|
|
default:
|
|
Fatal("Unknown secret type " + secret)
|
|
}
|
|
}
|