日期:2014-05-17 浏览次数:20679 次
public void decrypt(String file, String dest) throws Exception {
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, this.key, zeroIv);
InputStream is = new FileInputStream(file);
OutputStream out = new FileOutputStream(dest);
CipherOutputStream cos = new CipherOutputStream(out, cipher);
byte[] buffer = new byte[1024];
int r;
while ((r = is.read(buffer)) >= 0) {
cos.write(buffer, 0, r);
}
cos.close();
out.close();
is.close();
}
while ((r = is.read(buffer)) >= 0) {
cos.write(buffer, 0, r);
System.out.println(new String(buffer, 0, r));
}
public void decrypt(String file, String dest) throws Exception {
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, this.key, zeroIv);
InputStream is = new FileInputStream(file);
CipherInputStream cis = new CipherInputStream(in, cipher);
OutputStream os = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int r;
while ((r = cis.read(buffer)) >= 0) {
os.write(buffer, 0, r);
}
os.close();
cis.close();
}