java.lang.ArrayIndexOutOfBoundsException: too much data for RSA block

后端 未结 3 462
野趣味
野趣味 2021-01-03 13:46

I\'m using RSA encrypt text and decrypt text. The public key and the private key are generated with openssl tool. I encountered an \"java.lang.ArrayIndexOutOfBoundsException

3条回答
  •  醉酒成梦
    2021-01-03 14:07

    Usually, you generate a random secret key for a symmetric cipher (like AES) and use this to encrypt your pay load.

    RSA is then only used to encrypt this random key. This does not only solve the length problem but has some other advantages as well:

    • Symmetric cyphers are usually much faster
    • If the message is sent to several recievers, only the encrypted key has to be added specifically for each receiver, the main content can be the same.

提交回复
热议问题