Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes IllegalBlockSizeException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic


L Willie
Ranch Hand

Joined: Aug 10, 2008
Posts: 51
Error message "Exception:javax.crypto.IllegalBlockSizeException: Data must not be longer than 128 bytes" display when read the cipherMessage from ciphertext.txt* [ciphertext.txt can keep correct cipher message since the content same as System.out.println("Message encrypted with keystore public key:\n" + new String(ciphertextBytes) + "\n");]
and try to decrypt it.

NO such error message and decrypt properly ONLY IF direct read message from "ciphertextBytes " that i encrypt message,that is replace textBytes = cipher.doFinal(cipherMessageBytes); with textBytes = cipher.doFinal(ciphertextBytes);
moreover,the message also can not too long,otherwise it ll prompt another error message "Exception:javax.crypto.IllegalBlockSizeException: Data must not be longer than 117 bytes"

hence i guess might be wrong during read the "ciphertext.txt" especially convert the String cipherMessage to Byte[] cipherMessageBytes .am i wrong on this convert process??

Rob Spoor

Joined: Oct 27, 2005
Posts: 19651

That's the same question as this one. Let's continue in that thread, shall we?

How To Ask Questions How To Answer Questions
Don't get me started about those stupid light bulbs.
subject: IllegalBlockSizeException
Similar Threads
RSA decryption, BadPaddingException: Data must start with zero
signer information does not match? Help...
Have a problem when encrypt by RSA
invalidkeyspecexception - PKCS8EncodedKeySpec
Conversion problem