Input length (with padding) not multiple of 8 bytes - Lost Bytes ??
843810Apr 4 2002 — edited Apr 10 2002Hello,
I have implemented a small prog, which has to encryt a message and then to decrypt it. I use Blowfish with JDK1.4. Everything works fine.
Then I want to do this with a file. Encrypt a sourcefile and store the encryption in a destination. Then decrypt the destination.
But I get this exception: Input length (with padding) not multiple of 8 bytes
The strange thing is that I write 840 bytes and read 832 bytes:
Administrator@DIPCML01 /cygdrive/d/juraj/projekte/java/blowfish/ibm crypt
$ java Encrypt1 ../test.txt test3.txt key.txt
geschrieben: 840
Administrator@DIPCML01 /cygdrive/d/juraj/projekte/java/blowfish/ibm crypt
$ java Decrypt1 test3.txt key.txt test.txt
gelesen: 832
Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input length
(with padding) not multiple of 8 bytes
at com.sun.crypto.provider.BlowfishCipher.a(DashoA1275)
at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA1275)
at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA1275)
at javax.crypto.Cipher.doFinal(DashoA6275)
at Decrypt1.main(Decrypt1.java:47)
The read part:
byte[] encText1 = new byte[len1];
byte[] buff = new byte[len1];
// update the cipher with the data to be decrypted
while (bis.available() != 0)
{
len1 = bis.read(buff);
int countjlt = jceCipher.update(buff, 0, len1, encText1);
System.out.println("gelesen: " + countjlt);
}
The file stores only one row.
I use FileoutputStream to store the data and FileInputStream/BufferedInputStream to read the data. Can someone give me a answer where the exception causes or why I lost 8 bytes?
thanks
juraj