【发布时间】:2011-06-07 12:39:19
【问题描述】:
我尝试使用 AES 128 位密钥解密 4.2 MB .dcf 文件,但解密需要 33 秒(在函数 cipher.doFinal(data) 上),是否正常?
这是一个代码sn-p:
long start = System.currentTimeMillis()/1000L;
try {
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivspec);
android.util.Log.d("TEST", "Start decoding...." + String.valueOf(length));
byte[] decrypted = cipher.doFinal(content);
File file2 = new File(Environment.getExternalStorageDirectory().getPath() + "/test.mp3");
OutputStream os = new FileOutputStream(file2);
os.write(decrypted);
} catch (Exception ex) {
ex.printStackTrace();
}
long end = System.currentTimeMillis()/1000L;
android.util.Log.d("TEST","Time "+ String.valueOf(end-start));
【问题讨论】:
-
我预计这将取决于硬件 - 例如,我的 Desire 在某些事情上比我妻子的 Wildfire 快得多。你在试什么?
-
@MisterSquonk,我在模拟器上试了一下,大约需要 30-33 秒,在我的三星 Galaxy Spica 上,大约需要 25-30 秒。
-
如果您解释我将如何创建一个您正在解密的文件,我会在我的 HTC Desire (Froyo) 上尝试您的代码,如果它对您有用的话知道结果。
-
@MisterSquonk:我在朋友的 N1 上试过,只用了 2 秒。没错,这取决于硬件和 froyo(使用 jit 编译器)
-
哇,差别很大。有兴趣知道,感谢您的更新。
标签: android encryption aes