I am getting this error when trying to encrypt big messages. I wonder whether this is a limitation with rsa.rb or if I am doing something wrong. Did anyone bump against this error?
This is happening on the client side, where I am encrypting a huge message using the server's public key like this:
RSA::KeyPair.new(nil,server_public_key).encrypt(huge_base64_str)
This code blows up with the ArgumentError: message representative out of range when using the rsa gem
The best thing to do in this case is to encrypt the message with a symetric key (e.g. AES) and then encrypt the symetric key with rsa. and send the message and the encrypted symetric key.