KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > crypto > IllegalBlockSizeException

javax.crypto
Class IllegalBlockSizeException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.security.GeneralSecurityException
              extended by 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  

Popular Tags