aspose 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
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: 19762
    
  20

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