我发现Java 7引入了一个zip文件系统。目前我有一个加密的zip文件,我用以下代码解密
InputStream in = new FileInputStream(inFile);
Crypto algo = new Crypto();
algo.initV1();
in = new CipherInputStream(in, algo.getCiphertoDec(in, pass));
ZipInputStream zipInput = new ZipInputStream(in);
ZipEntry ze = zipInput.getNextEntry();
....
并且方法getCiphertoDec就像这样
public Cipher getCiphertoDec (InputStream in, String password) throws Exception {
byte[] salt = new byte[SALT_SIZE_BYTE];
if (in.read(salt) < SALT_SIZE_BYTE) {
throw new IllegalArgumentException("Invalid file length (needs a full block for salt)");
};
key = CoreCryptoV1.PBKDF2.pbkdf2(password, salt, 1000);
ivBytes = new byte[IV_LENGTH_BYTE];
if (in.read(ivBytes) < IV_LENGTH_BYTE) {
throw new IllegalArgumentException("Invalid file length (needs a full block for iv)");
};
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(ivBytes));
return cipher;
}
我想知道是否有办法将加密的zip文件视为文件系统。 我很感激任何建议。 我想要一个与android兼容的解决方案。