Large data not encrypted with RSA Encryption

前端 未结 2 509
我在风中等你
我在风中等你 2021-01-02 08:44

My Problem:

My encryption code working fine for below 64 characters. but if it exceeds 64 character I got following error<

2条回答
  •  北海茫月
    2021-01-02 09:26

    The number of bytes you can encrypt in one RSA block is dictated by the key size used minus any bytes taken up for padding.

    Generally RSA is not suited for bulk encryption as it's quite slow. Instead use a symmetric encryption algorithm like AES if you can. If you really need the two key's of RSA, use a Hybrid approach where you encrypt the data with a random symmetric key, and then encrypt that key with the RSA key.

    A benefit of using symmetric encryption is also that the libraries automatically supports bulk encryption - which they don't for RSA.

提交回复
热议问题