I have a message contained in byte [] encrypted with "RSA / ECB / PKCS1Padding". To decrypt it, I create Cipher c and initiate it with
c = Cipher.getInstance("RSA/ECB/PKCS1Padding");
So far, I only have decrypted small messages using the doFinal () method, returning byte [] with decrypted bytes.
c.init(Cipher.DECRYPT_MODE, privateKey); byte[] decryptetBytes = c.doFinal(encryptedBytes);
But in this case, the data is larger (about 500 bytes), and the doFinal () method throws an exception (javax.crypto.IllegalBlockSizeException: the data should not be longer than 128 bytes). I think I need to use the update () method, but I cannot figure out how to make it work correctly. How it's done?
source share