是否有可能在android中访问运行时解密文件?

时间:2014-10-20 13:20:19

标签: android encryption

我想要解密存储在我应用的res文件夹中的文件。此文件随应用程序一起分发,我在应用程序启动期间只尝试解密一次。

到目前为止,我已经找到了一些关于如何将解密文件写入SD卡的答案(this one, for instance),但是不知道该文件是否可以在SD卡上进行恶意访问?

我希望我可以将CipherInputStream写入java.io.InputStream,这样我就可以在不将任何解密数据写入磁盘的情况下使用它。有可能吗?

1 个答案:

答案 0 :(得分:1)

我想你想要这样的东西

private InputStream getDecodedInputStream (InputStream eis) {
   Cipher cipher = Cipher.getInstance("your cipher definition");
   cipher.init(Cipher.DECRYPT_MODE, "your keySpec", new IvParameterSpec("your IV parameter spec"));
   InputStream decryptedInputStream = new CipherInputStream(is, cipher);
   return decryptedInputStream;
}

其中eis是您的加密输入流

相关问题