// Copyright 2018 Drone.IO Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cmd import ( "crypto/rand" "encoding/base64" "fmt" "os" "golang.org/x/crypto/ed25519" ) // var out = flag.String("out", "id_ed25519", "") type Args struct { Out string } func LicenseKeyGen(args Args) { publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader) if err != nil { fmt.Println(err) os.Exit(1) } publicKeyHex, privateKeyHex := base64.StdEncoding.EncodeToString(publicKey), base64.StdEncoding.EncodeToString(privateKey) err = os.WriteFile(args.Out, []byte(privateKeyHex), 0644) if err != nil { fmt.Println(err) os.Exit(1) } err = os.WriteFile(args.Out+".pub", []byte(publicKeyHex), 0644) if err != nil { fmt.Println(err) os.Exit(1) } }