不同 PHP mcrypt 算法的速度
嘿伙计们。今天我正在测试 php mcrypt 算法。
我运行了一个测试来检查不同 mcrypt 算法的速度。
测试算法: Cast-128、Gost、Rijndael-128、Twofish、Cast-256、Loki97、Rijndael-192、Saferplus、Blowfish-compat、Des、Rijndael-256、Serpent、Xtea 、河豚、Rc2、Tripledes。
测试在 ECB 模式下运行(您还可以使用:CBC、CFB、CTR、ECB、NCFB、NOFB、OFB)。
我加密了一个简单的字符串:“这是一个测试”。以下结果是 1000 次迭代的结果(结果以秒为单位)。
河豚 0.5217170715332
河豚鱼 0.46304702758789
CAST 128 0.19502091407776
CAST 256 0.28649806976318
DES 0.45267295837402
GOST 0.19383502006531
LOKI97 0.27537798881531
RC2 0.44201898574829
RIJNDAEL 128 0.2560601234436
RIJNDAEL 192 0.33414602279663
RIJNDAEL 256 0.42553782463074
SAFERPLUS 0.32848501205444
蛇 0.391037940979
三倍 0.65123796463013
两条鱼 0.27349305152893
XTEA 0.37829685211182
当然,当我们谈论安全性时,处理时间并不是最重要的事情。我只是想分享我的结果。
您使用什么 mcrypt 算法和模式,为什么? 我知道这取决于情况、安全级别等,但请举一些例子。
Hy guys. Today I was testing the php mcrypt algorithms.
I run a test to check the speed of different mcrypt algos.
Tested algorithms: Cast-128, Gost, Rijndael-128, Twofish, Cast-256, Loki97, Rijndael-192, Saferplus, Blowfish-compat, Des, Rijndael-256, Serpent, Xtea, Blowfish, Rc2, Tripledes.
The test was run in ECB mode (you also can use: CBC, CFB, CTR, ECB, NCFB, NOFB, OFB).
I encrypted a simple string: "This is a test". The following results are for 1000 iterations (results are in second).
BLOWFISH
0.5217170715332BLOWFISH COMPAT
0.46304702758789CAST 128
0.19502091407776CAST 256
0.28649806976318DES
0.45267295837402GOST
0.19383502006531LOKI97
0.27537798881531RC2
0.44201898574829RIJNDAEL 128
0.2560601234436RIJNDAEL 192
0.33414602279663RIJNDAEL 256
0.42553782463074SAFERPLUS
0.32848501205444SERPENT
0.391037940979TRIPLEDES
0.65123796463013TWOFISH
0.27349305152893XTEA
0.37829685211182
Of course that process time is not the most important thing when we talk about security. I just want to share my results.
What mcrypt algo and mode are you using, and why?
I know that it depends on the situation, security level, etc. but give some examples please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是 PHP(对称密码)中 MCrypt 与 OpenSSL 速度比较的完整测试基准:
Mcrypt 较旧,但文档更好,库速度明显慢,但输出非常一致。 OpenSSL 更新、更快且文档较少。
如果您首先关心性能,那么请选择 OpenSSL CFB/ECB 256 位算法。
请注意,Intel Core i3/i5/i7 支持AES 指令集,可以将每个线程的 I/O 吞吐量从 11 MB/秒大幅提高到 700 MB/秒 - 请参阅http://en.wikipedia.org/wiki/Advanced_Encryption_Standard。
Here is full test benchmark for speed comparison for MCrypt versus OpenSSL in PHP (symmetric cyphers):
Mcrypt is older but better documented and significantly slower library, but very consistent output. OpenSSL is newer, faster and less documented.
If you care about performance in first place, then go with OpenSSL CFB/ECB 256-bit algo.
Note, that Intel Core i3/i5/i7 support AES instruction set that can extremly increase I/O throughput from 11 MB/sec to 700 MB/sec per thread - see http://en.wikipedia.org/wiki/Advanced_Encryption_Standard.
我正在使用 AES 256 (
MCRYPT_RIJNDAEL_256
),为什么?由于该算法的知名度和广泛使用。我还使用 CBC 模式进行加密,我不明白其确切原因,但从我从各种来源读到的内容来看,它比 ECB 更可靠(如安全)。另外,请记住,当您处理散列和/或加密时,速度不是您的朋友(原因很简单:如果速度快,破解速度也会更快强>)。
I am using AES 256 (
MCRYPT_RIJNDAEL_256
), why? Because of the algorithm notoriety and widespread usage. I'm also encrypting usingCBC
mode, I don't understand exactly the reason why but from what I read from various sources it's much more reliable (as in secure) than ECB.Also, keep in mind that when you're dealing with hashing and/or encryption speed is not your friend (the reason for that is simple: if it's fast, it's faster to crack).