Created
March 19, 2019 10:40
-
-
Save chackett/86123a6b3936e4debad37f184a582300 to your computer and use it in GitHub Desktop.
Create RSA Public Private Keys in PEM format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
privateKey, err := rsa.GenerateKey(rand.Reader,2048) | |
privKey := pem.EncodeToMemory(&pem.Block{ | |
Type: "RSA PRIVATE KEY", | |
Bytes: x509.MarshalPKCS1PrivateKey(privateKey), | |
}) | |
pubKey := pem.EncodeToMemory(&pem.Block{ | |
Type: "RSA PUBLIC KEY", | |
Bytes: x509.MarshalPKCS1PublicKey(&privateKey.PublicKey), | |
}) | |
fmt.Println("------------------------") | |
fmt.Println(string(privKey)) | |
fmt.Println("------------------------") | |
fmt.Println(string(pubKey)) | |
fmt.Println("------------------------") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment