Does Crypto.RSAEncrypt have a size limit?

I am testing the sending of text from a client to server application. I have generated a Public key and encode it as Base64. The text I want to send may have non-ASCII characters, so I Hex it. Normally the below line works fine, but I have been testing it will lots of characters.

Return Crypto.RSAEncrypt(EncodeHex(Data), DecodeBase64(PublicKey))

With too many characters, it gives the following CryptoException error:

Even if I use 10,000 or less characters, it gives the same error. Is there a size limit?

Yes, RSA is not designed or recommended for that type of encryption. Consider using it to send an encryption key instead, then encrypt the actual data with that key using something like AES.

Thanks for the clear-up. I’m rebuilding my client-server socket communication to be generic so I can re-use it in all my applications.