aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/gitolfs3-gen-ed25519-key
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/gitolfs3-gen-ed25519-key')
-rw-r--r--cmd/gitolfs3-gen-ed25519-key/main.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/gitolfs3-gen-ed25519-key/main.go b/cmd/gitolfs3-gen-ed25519-key/main.go
new file mode 100644
index 0000000..8288fd1
--- /dev/null
+++ b/cmd/gitolfs3-gen-ed25519-key/main.go
@@ -0,0 +1,31 @@
1package main
2
3import (
4 "crypto/ed25519"
5 "crypto/rand"
6 "encoding/hex"
7 "fmt"
8 "os"
9)
10
11func wipe(b []byte) {
12 for i := range b {
13 b[i] = 0
14 }
15}
16
17func main() {
18 publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)
19 if err != nil {
20 fmt.Fprintf(os.Stderr, "Failed to generate ED25519 key: %s", err)
21 os.Exit(1)
22 }
23 defer wipe(privateKey)
24
25 enc := hex.NewEncoder(os.Stdout)
26 print("Public ")
27 enc.Write(publicKey)
28 print("\nPrivate ")
29 enc.Write(privateKey.Seed())
30 println()
31}