android如何加密所有的布局文件夹,android:是否可以加密文件夹

对不起,提出这个问题,但我没有清楚的加密和解密文件夹的想法,我想加密一堆选定的图像,如在这篇文章encrypt/decrypt中提到的,但它是服用大量的时间来加密一堆选择的图像,所以我试图加密包含一个文件夹中选中的图像,但它给我FileNotFoundException异常:打开失败(是一个目录)我已经更新了加密功能,如下图所示android:是否可以加密文件夹

static void encrypt() throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {

// Here you read the cleartext.

FileInputStream fis = new FileInputStream(Environment.getExternalStorageDirectory()+"/.myapp/.private");

// This stream write the encrypted text. This stream will be wrapped by another stream.

FileOutputStream fos = new FileOutputStream(Environment.getExternalStorageDirectory()+"/.myapp/.encyrpted");

// Length is 16 byte

SecretKeySpec sks = new SecretKeySpec("MyDifficultPassw".getBytes(), "AES");

// Create cipher

Cipher cipher = Cipher.getInstance("AES");

cipher.init(Cipher.ENCRYPT_MODE, sks);

// Wrap the output stream

CipherOutputStream cos = new CipherOutputStream(fos, cipher);

// Write bytes

int b;

byte[] d = new byte[8];

while((b = fis.read(d)) != -1) {

cos.write(d, 0, b);

}

// Flush and close streams.

cos.flush();

cos.close();

fis.close();}

所以我如何加密文件夹sdcard/.myapp/.private,这样我可以减少加密整个图像的时间?

+0

看到这可能是对你有帮助。 http://stackoverflow.com/questions/6266076/can-we-encrypt-a-folder-in-android –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值