AES256加密/解密速度 [英] AES256 Encryption/Decryption speed

查看:1739
本文介绍了AES256加密/解密速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写这些加密和解密文件的应用程序。我使用AES256位密码使用CipherInputStream和CipherOutputStream为enryption /解密过程。

I am writing an application which encrypts and decrypts files. I am using CipherInputStream and CipherOutputStream for enryption/decryption process using AES256 bit cipher.

我的问题是,如果我把字节数组,写入文件的飞行大约需要2倍的时间比我是否解密文件中创建一个字节数组makeing加密。因为我了解AES加密和解密是对称的过程,他们应该采取的时间相同数额来完成这很奇怪。

My problem is if I take byte array and write to file makeing encryption on the fly it takes about 2 times less time than if I decrypt file creating a byte array. It is strange because as I know AES encryption and decryption are symmetric processes and they should take same amount of time to complete.

任何想法?

推荐答案

有很多在这里的贴子#2抱怨慢I / Android上的O操作。很多时候,问题是一个坏块大小为执行日写操作。

There are a lot of postings here on Stackoverflow complaining about slow I/O operations on Android. Very often the problem is a bad block-size for performing th write operations.

在智能手机中使用闪存组织了几千字节的大块 - 因此最佳写入速度,你应该只写它的4KB块或多个

Flash memory as used in Smartphones is organized in large blocks of several kilobytes - therefore for optimal write speed you should only write blocks of 4KB or multiple of it.

这是8字节的块加密算法AES一样工作逐块 - 这可能会导致大量的性能消耗

Ciphers like AES work block-wise on blocks of 8 bytes - this may lead to massive performance drain.

我建议通过的BufferedOutputStream 4或16KB的缓冲器大小发送CipherOutputStream的输出。这应该显著加快行动的过程。

I would recommend to send the output of the CipherOutputStream through a BufferedOutputStream with a buffer size of 4 or 16 KB. This should significantly speed-up the process.

此外,你必须考虑写入到闪存总是比读书更慢。

Additionally you have to consider that writing to flash memory is always slower than reading.

这篇关于AES256加密/解密速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆