AESCrypt - Very slow file encryption
Dear, I'm using AESCrypt to keep the encrypted music and videos in my Player.
I used the following function to encrypt all media directory
Code :
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);
}
At run time, do the decryption putting a new file as tmp just to run.
Code :
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?
Re: AESCrypt - Very slow file encryption
AESCrypt is a third-party library; found here: Using AES Crypt - Advanced File Encryption for Java
Please always inform us of such facts in future posts.
The answer is that it all depends on how the AESCrypt library is implemented. Does the library only work with temp files? or is that your own 'hack'?
Decrypting large media files is never going to be instant really.