Tal*_*nel 2 filesystems encryption android android-sdcard
我希望有人能告诉我一种方法,当设备连接到设备上的USB存储模式/内部文件浏览应用程序时,SD卡上的文件夹被隐藏/不可见/加密.
我还需要能够从我的Android应用程序访问这些文件(只有在它有任何不同的情况下才能读取它们.)
我知道一些文件加密应用程序,如SecretVault pro,但像这样的应用程序没有开发人员的API,允许逐步控制加密/破坏状态.
Jac*_*lai 15
public byte[] keyGen() throws NoSuchAlgorithmException {
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(192);
return keyGenerator.generateKey().getEncoded();
}
Run Code Online (Sandbox Code Playgroud)
你需要在你的应用程序中存储密钥
public byte[] encript(byte[] dataToEncrypt, byte[] key)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
//I'm using AES encription
Cipher c = Cipher.getInstance("AES");
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.ENCRYPT_MODE, k);
return c.doFinal(dataToEncrypt);
}
public byte[] decript(byte[] encryptedData, byte[] key)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
Cipher c = Cipher.getInstance("AES");
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.DECRYPT_MODE, k);
return c.doFinal(encryptedData);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1388 次 |
最近记录: |