Import string RSA public key to encrypt with RSA in Golang

Hi all!

So I am having a hard time finding how to simply import an RSA public key from a string in Go.

My program should do the following:

  • Receives a public key encoded in base64 (that works)
  • Decode this public key from base64 to bytes (that works)
  • Import that public key so that it is usable by the RSA implementation of Go (Problem is at this stage)
  • Encrypt an AES key with this rsa.EncryptOAEP(sha256.New(), rand.Reader, publicKey, plaintextBytes, []byte(""))

Thanks !

The RSA public key consists of two large integers. These will have been encoded into bytes into some manner. Do you know the encoding of the bytes you get as base64? One common variant is PKIX.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.