go-http-peering/cmd/keygen/create_key.go

24 lines
408 B
Go
Raw Normal View History

2019-02-22 17:35:49 +01:00
package main
import (
"fmt"
"forge.cadoles.com/Cadoles/go-http-peering/crypto"
2019-02-22 17:35:49 +01:00
)
func createKey() {
passphrase, err := getPassphrase()
if err != nil {
handleError(err)
}
key, err := crypto.CreateRSAKey(keySize)
if err != nil {
handleError(err)
}
privatePEM, err := crypto.EncodePrivateKeyToEncryptedPEM(key, passphrase)
if err != nil {
handleError(err)
}
fmt.Print(string(privatePEM))
}