没有找到 winRar 的密码策略,这个完全是自己拍脑袋的
解决方案 »
- gridview中 intent传数据问题
- 初学Android,请教handler.removeCallbacks的问题
- 求助:Android层与linux层的通信
- android平台运行html5网页怎么去掉地址栏
- 如何在Android中实现像地图那样的功能对图片进行操作?
- 为什么别人会的帖子全都不存在了
- onItemClick方法中的position和id是什么意思?
- android studio build error 求助
- 这个build.gradle要怎么改啊.
- android配置失败
- Activity中不能显示Dialog
- 在framework中如何去执行一个home key的键功能
恩 最近在搞这个玩意 不过加密后的zip文件 不能被winRar 识别,只能用自己的程序解密,本来是想做成通用格式的
return;
} else {
byte[] bytepass = pwd.getBytes();
FileInputStream fs = new FileInputStream(t_file);
FileOutputStream out = new FileOutputStream(file);
if (fs != null) {
int filelen = fs.available();
byte[] real = new byte[filelen];
fs.read(real, 0, filelen);
SecretKeyFactory keyfac = SecretKeyFactory.getInstance("DES");
byte[] keydata;
keydata = bytepass;
DESKeySpec keySp = new DESKeySpec(keydata);
Key key = keyfac.generateSecret(keySp);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] cipherText = cipher.doFinal(real);
byte[] all = new byte[cipherText.length + bytepass.length];
System.arraycopy(bytepass, 0, all, 0, bytepass.length);
System.arraycopy(cipherText,0, all, bytepass.length, cipherText.length); out.write(all);
}
fs.close();
out.close();
return;
}
else {
byte[] bytepass = pwd.getBytes();
FileInputStream fs = new FileInputStream(sec_file);
FileOutputStream out = new FileOutputStream(zipfile);
if (fs != null) {
int filelen = fs.available();
byte[] all = new byte[filelen];
fs.read(all, 0, filelen);
System.arraycopy(all, 0, bytepass, 0, bytepass.length); byte[] real = new byte[filelen-bytepass.length];
System.arraycopy(all, bytepass.length, real, 0, real.length);
SecretKeyFactory keyfac = SecretKeyFactory.getInstance("DES");
byte[] keydata;
keydata = bytepass;
DESKeySpec keySp = new DESKeySpec(keydata);
Key key = keyfac.generateSecret(keySp);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] cipherText = cipher.doFinal(real);
out.write(cipherText);
}
fs.close();
out.close();