この質問をして申し訳ありませんが、フォルダーの暗号化と復号化の明確なアイデアが得られません。この投稿の 暗号化/復号化で述べたように、選択した画像の束を暗号化しようとしていますが、選択した画像の束を暗号化するのに多くの時間がかかっていますそのため、選択した画像を含むフォルダーを暗号化しようとしましたが、filenotfoundexception:open failed(is a directory) が表示されます。以下に示すように暗号化機能を更新しました。
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 を暗号化して、大量の画像全体を暗号化する時間を短縮するにはどうすればよいですか??