CipherInputStream and CipherOutputStream are not generating files

后端 未结 1 1400
离开以前
离开以前 2020-12-10 10:10

I have the following code. However the files b.xlsx and c.xlsx are of 0 bytes. Why is CipherOuputSteam not working?

         


        
1条回答
  •  [愿得一人]
    2020-12-10 10:48

    The problem lies in your usage - which is incorrect and in the implementation of CipherOutputStream which masks a very important exception - IllegalBlockSizeException.

    The problem is that you cannot use an RSA key to encrypt data which is longer than the size of the key (which is 128 bytes in your example). you should use a symmetric encryption algorithm for large blocks of data - e.g. AES.

    If you want to use asymmetric keys for a reason (safe transmition of data for example) - you can find a good example on this SO answer.

    0 讨论(0)
提交回复
热议问题