I used the following function to encrypt all media directory
Code: Select all
public static void encryptMusic(){
String args1[] = new String[4];
args1[0] = "e"; // encrypt
args1[1] = "pass";
AESCrypt aes;
File filecryptss = new File("/home/dinho/midiasOLD");
File fList[] = filecryptss.listFiles();
for ( int i = 0; i < fList.length; i++ ){
args1[2] = "/home/dinho/midiasOLD/" + fList[i].getName();
args1[3] = "/home/dinho/midias/" + fList[i].getName();;
try {
aes = new AESCrypt(false, args1[1]);
aes.criptografar(args1);
} catch (UnsupportedEncodingException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (GeneralSecurityException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
};
System.out.println("Arquivo criptografado: " + fList[i].getName());
System.out.println("Deletando arquivo: " + fList[i].getName() + "...");
fList[i].delete(); // deleto o arquivo para não ocupar espaço
}
System.exit(0);
}
Code: Select all
String args1[] = new String[4];
args1[0] = "d"; // decrypt
args1[1] = "pass";
args1[2] = "/home/dinho/midias/video.avi";
args1[3] = "/home/dinho/midias/tmp_video.avi";
AESCrypt aes;
try {
aes = new AESCrypt(false, args1[1]);
aes.criptografar(args1);
} catch (UnsupportedEncodingException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (GeneralSecurityException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
};
After running the tmp file, it is removed from the directory.
The problem I face is that when selecting a video file, depending on size, can take up to one minute only to decrypt.
The question is:
Is there a way to decrypt without the need to create a new physical file?
I'm at least on the right track or is there a better way to do this whole process?