From: <nbr...@to...> - 2002-10-30 05:58:32
|
Hi, I'm using this stuff for the first time, but am bemused by the following: The javadoc for xjava.security.Cipher states that all versions of crypt() automatically pad/unpad as necessary. =20 But a simple test case for Rijndael: String message =3D "Dennis eats worms."; Cipher cipher =3D Cipher.getInstance(algorithm); cipher.initEncrypt(new RawSecretKey(algorithm, key));=20 byte[] encryptedMessage =3D cipher.crypt(message.getBytes()); cipher.initDecrypt(new RawSecretKey(algorithm, key)); byte[] unencryptedMessage =3D cipher.crypt(encryptedMessage); System.out.println("message=3D" + new String(unencryptedMessage));= Throws the following exception: Exception in thread "main" xjava.security.IllegalBlockSizeException: Rijndael: Non-padding cipher in ENCRYPT state with an incomplete final block at xjava.security.Cipher.updateInternal(Cipher.java:1264) at xjava.security.Cipher.crypt(Cipher.java:1046) at xjava.security.Cipher.crypt(Cipher.java:1011) at com.touchcorp.test.Encrypt.main(Encrypt.java:46) Either the javadoc or the code appears to be wrong. Help? Neil Brennan |