java.lang.Object
java.lang.Throwable
java.lang.Exception
java.security.GeneralSecurityException
javax.crypto.IllegalBlockSizeException
- All Implemented Interfaces:
- Serializable
- See Also:
- Top Examples, Source Code
public IllegalBlockSizeException()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1566]RSA algorithm encryption length
By Anonymous on 2005/10/08 18:11:52 Rate
//This piece of code could give you javax.crypto.IllegalBlockSizeException: Data must not be longer than 245 bytes
Cipher cipher = Cipher.getInstance ( "RSA" ) ;
cipher.init ( Cipher.ENCRYPT_MODE, rsaPublic ) ;
encryptedData = cipher.doFinal ( originalData ) ;
//The RSA algorithm can only encrypt data that has a maximum byte length of the RSA key length in bits divided with eight minus eleven padding bytes, i.e. number of maximum bytes = key length in bits / 8 - 11. In your case it means 2048 / 8 - 11 = 245. If you want to encrypt larger data, then use a larger key, for example, a key with 4096 bits will allow you to encrypt 501 bytes of data.
public IllegalBlockSizeException(String msg)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples