我有这个代码来加密视频文件。加速加密?
public static void encryptVideos(File fil,File outfile)
{
try{
FileInputStream fis = new FileInputStream(fil);
//File outfile = new File(fil2);
int read;
if(!outfile.exists())
outfile.createNewFile();
FileOutputStream fos = new FileOutputStream(outfile);
FileInputStream encfis = new FileInputStream(outfile);
Cipher encipher = Cipher.getInstance("AES");
KeyGenerator kgen = KeyGenerator.getInstance("AES");
//byte key[] = {0x00,0x32,0x22,0x11,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
SecretKey skey = kgen.generateKey();
//Lgo
encipher.init(Cipher.ENCRYPT_MODE, skey);
CipherInputStream cis = new CipherInputStream(fis, encipher);
while((read = cis.read())!=-1)
{
fos.write(read);
fos.flush();
}
fos.close();
}catch (Exception e) {
// TODO: handle exception
}
}
但我使用的文件非常大,使用这种方法需要很多时间。 我该如何加快速度?
Encyrption是资源密集型的。整个想法是,你正在以一种复杂的方式破坏内容。 – mcfinnigan 2012-02-29 11:08:54
你得到什么样的速度?你有没有尝试*映射*文件,并在ByteBuffer的返回(ps不知道,如果这可能为android,忽略标签)执行加密? – 2012-03-01 00:45:26
我是新手我不知道它的可能 – Navdroid 2012-03-01 05:19:46