File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

IllegalBlockSizeException

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
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalBlockSizeException
 
Similar Threads
Have a problem when encrypt by RSA
signer information does not match? Help...
invalidkeyspecexception - PKCS8EncodedKeySpec
Conversion problem
RSA decryption, BadPaddingException: Data must start with zero