1

Sorry for asking this question but i am not getting clear idea of encrypting and decrypting a folder, I am trying to encrypt a bunch of selected images as mentioned in this post encrypt/decrypt but it is taking lot of time to encrypt bunch of selected images,so i tried to encrypt a folder containing selected images but it is giving me filenotfoundexception:open failed(is a directory) I have updated encrypt function as shown below

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();}

so how do i encrypt folder sdcard/.myapp/.private so that i can reduce time in encrypting whole bunch of images??

Community
  • 1
  • 1
Mahantesh M Ambi
  • 786
  • 1
  • 13
  • 25

1 Answers1

0

I think you want to encrypt folder as well as sub contain data.

See this may be its helpful to you.

Can we Encrypt a folder in android?

Community
  • 1
  • 1
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
  • sorry i am new to android,i saw that post before posting my question,. but i dint get any idea on how to encrypt a particular folder,link was vague for me to understand – Mahantesh M Ambi Nov 12 '12 at 12:14
  • try this http://stackoverflow.com/questions/7787328/rsa-encrypt-and-decrypt-strings-on-android i am not sure it will works for folder – Chintan Khetiya Nov 12 '12 at 12:38
  • i think you should encrypt and decrepit zip folder try this http://stackoverflow.com/questions/10222284/encrypting-and-decrypting-a-zip-file-in-android – Chintan Khetiya Nov 12 '12 at 12:41
  • Thanks for your response but i just want to hide or encrypt a folder so that other person must not be able to see my hidden pictures,i was able to hide the images using the link i mentioned but it is taking lot of time so i thought i will hide/encrypt folder so that person exploring my sdcard wont be able to see images inside hidden folder – Mahantesh M Ambi Nov 12 '12 at 13:28