david-lshift / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

Generating a mail with an encrypted zip attachment without any temp file #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
HI
I want to produce a encrypted zip file and send it by E-mail, therefore I send 
the attachment by ByteArrayOutputStream and it does not generate any temp file. 
However, the attach zip file cannot be opened successfully. Then I try to use 
different approach to verify if the ByteArrayOutputStream may have some problem 
while generating output data.
/** It generates a zip file by the following code successfully **/
String password = "1234";
AESEncrypter aesEncrypter = new AESEncrypterBC();
aesEncrypter.init(password, 0);
AesZipFileEncrypter ze = new AesZipFileEncrypter("D:/VrsBill/20150305.zip", 
aesEncrypter);
//AesZipFileEncrypter ze = new AesZipFileEncrypter(baos, aesEncrypter);
InputStream inputStream = new FileInputStream("D:/VrsBill/20150305.txt");                    

ze.add("abc.txt", inputStream, password);
inputStream.close();
ze.close();
baos.close();   
/** Comment End **/

/** It generates a zip file by ByteArrayOutputStream indirectly and the zip 
file cannot be opened successfully **/
ByteArrayOutputStream baos = new ByteArrayOutputStream();               
String password = "1234";
AESEncrypter aesEncrypter = new AESEncrypterBC();
aesEncrypter.init(password, 0);
//AesZipFileEncrypter ze = new AesZipFileEncrypter("D:/VrsBill/20150305.zip", 
aesEncrypter);
AesZipFileEncrypter ze = new AesZipFileEncrypter(baos, aesEncrypter);
InputStream inputStream = new FileInputStream("D:/VrsBill/20150305.txt");                        

ze.add("abc.txt", inputStream, password);                   
FileOutputStream fos = new FileOutputStream("D:/VrsBill/20150305.zip");
fos.write(baos.toByteArray());
fos.close();
inputStream.close();
ze.close();
baos.close();
/** Comment End **/

What version of the product are you using? On what operating system?
Eclipse 3.2 with JDK 1.6.0_45, Windows 7 64 Bit.

Please provide any additional information below.
The source file is just a pure text file. This project use bcprov-jdk16-146.jar 
and winzipaes-1.0.1.jar to zip and encrypt the file.

I really need your help and thanks a lot.

Original issue reported on code.google.com by aluba0...@gmail.com on 30 Jun 2015 at 8:55

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Please skip and delete this issue, sorry.

Original comment by aluba0...@gmail.com on 30 Jun 2015 at 9:26

GoogleCodeExporter commented 9 years ago
closed as requested

Original comment by olaf.merkert on 30 Jun 2015 at 1:25