Closed GoogleCodeExporter closed 8 years ago
closed as requested
Original comment by olaf.merkert
on 30 Jun 2015 at 1:25
[deleted comment]
Why close this issue? Please close issue #51 but keep issue #52 open, thanks.
Original comment by aluba0...@gmail.com
on 1 Jul 2015 at 1:31
Original comment by olaf.merkert
on 1 Jul 2015 at 7:46
did you have a look at this encrypter testcase already?
https://code.google.com/p/winzipaes/source/browse/trunk/winzipaes/tests/src.test
/de/idyl/winzipaes/TestAesZipFileEncrypter.java
Original comment by olaf.merkert
on 1 Jul 2015 at 8:15
HI
Thanks for your response.
I rewrite the method testWithOutputStream() of your sample.
/*********************/
public class TestAesZipFileEncrypter
{
public void test() throws Exception
{
String PASSWORD = "1234";
OutputStream bao = new ByteArrayOutputStream();
AESEncrypter encrypter = new AESEncrypterBC();
AesZipFileEncrypter enc = new AesZipFileEncrypter(bao, encrypter);
enc.add("20150305.txt", new FileInputStream("D:/VrsBill/20150305.txt"), PASSWORD);
//Convert data saved in ByteArrayOutputStream to File
FileOutputStream fos = new FileOutputStream("D:/VrsBill/20150305.zip");
fos.write(((ByteArrayOutputStream)bao).toByteArray());
//Comment End
fos.close();
enc.close();
}
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
TestAesZipFileEncrypter test = new TestAesZipFileEncrypter();
test.test();
}
}
/**********************************/
I try to write data which is saved in the ByteArrayOutputStream to the
FileOutputStream (file). However, the output file (20150305.zip) can not be
opened successfully. It means that the generated file is an invalid zip file.
Original comment by aluba0...@gmail.com
on 3 Jul 2015 at 2:30
I'm don't quite understand, what you're trying to achieve:
Do you simply want to create a zip file that contains the file
D:/VrsBill/20150305.txt as an encrypted entry or is it something else?
Original comment by olaf.merkert
on 3 Jul 2015 at 5:27
[deleted comment]
I want to send mail with an encrypted zip attachment, and all steps are
processed in the memory. Therefore, I use ByteArrayOutputStream instead of
FileOutputStream sending mail. However, the zip attachment which is generated
by your API (using ByteArrayOutputStream) is corrupted. Therefore, at the final
step of above code, I use FileOutputStream to verify if the encrypted zip data
saved in the ByteArrayOutputStream is valid zip format. Unfortunately, the file
is corrupted, and I can not open it successfully. That means there is some
problem happening while using ByteArrayOutputStream to generate encrypted zip
data.
Original comment by aluba0...@gmail.com
on 6 Jul 2015 at 2:02
In TestAesZipFileEncrypter.testWithOutputStream() you can see, that the test
ends with a call to "enc.close()". This call is required before you write the
bytes of the ByteArrayOutputStream anywhere, as it adds the "central directory"
at the end of the zip "file".
Original comment by olaf.merkert
on 6 Jul 2015 at 7:36
HI
I use your suggestion and correct the code. (Closing AesZipFileEncrypter before
writing the bytes of the ByteArrayOutputStream) It works good now.
Thanks a lot.
Original comment by aluba0...@gmail.com
on 9 Jul 2015 at 3:09
Original comment by olaf.merkert
on 9 Jul 2015 at 8:06
Original issue reported on code.google.com by
aluba0...@gmail.com
on 30 Jun 2015 at 9:09