Skip to content

Instantly share code, notes, and snippets.

@tkrs
Last active August 29, 2015 14:11
Show Gist options
  • Save tkrs/5083d4d93756b2d13f1c to your computer and use it in GitHub Desktop.
Save tkrs/5083d4d93756b2d13f1c to your computer and use it in GitHub Desktop.
Generate rsa public key
package main
import (
"crypto/rand"
"crypto/rsa"
"log"
)
func main() {
privKey, err := rsa.GenerateKey(rand.Reader, 1024)
if err != nil {
log.Fatal("[rsa.GenerateKey] ", err)
return
}
privKey.Precompute()
if err := privKey.Validate(); err != nil {
log.Fatal("[privKey.Validate] ", err)
return
}
pubKey := privKey.Public()
log.Println(pubKey)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment