计算MD5哈希值比SHA系列函数少CPU密集度? [英] Is calculating an MD5 hash less CPU intensive than SHA family functions?

查看:511
本文介绍了计算MD5哈希值比SHA系列函数少CPU密集度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计算MD5散列比标准笔记本电脑x86硬件上的SHA-1或SHA-2少CPU密集?我对一般信息感兴趣,而不是特定于某个芯片。

Is calculating an MD5 hash less CPU intensive than SHA-1 or SHA-2 on "standard" laptop x86 hardware? I'm interested in general information, not specific to a certain chip.

UPDATE:
在我的例子中,有兴趣计算文件的哈希值。如果文件大小很重要,让我们假设它的300K。

UPDATE: In my case, I'm interested in calculating the hash of a file. If file-size matters, let's assume its 300K.

推荐答案

是的,MD5有点少CPU占用。在我的英特尔x86(Core2 Quad Q6600,2.4 GHz,使用一个核心),我得到这个在32位模式:

Yes, MD5 is somewhat less CPU-intensive. On my Intel x86 (Core2 Quad Q6600, 2.4 GHz, using one core), I get this in 32-bit mode:

MD5       411
SHA-1     218
SHA-256   118
SHA-512    46

而在64位模式下:

MD5       407
SHA-1     312
SHA-256   148
SHA-512   189

数字以兆字节/一个长的消息(这是你得到的消息超过8 kB)。这是使用 sphlib ,a C(和Java)中的散列函数实现库。所有实现都来自相同的作者(我),并且在优化时做出了类似的努力;因此速度差异可以被认为是功能真正固有的。

Figures are in megabytes per second, for a "long" message (this is what you get for messages longer than 8 kB). This is with sphlib, a library of hash function implementations in C (and Java). All implementations are from the same author (me) and were made with comparable efforts at optimizations; thus the speed differences can be considered as really intrinsic to the functions.

作为比较,考虑到最近的硬盘将以大约100MB / s运行,而任何超过USB的东西都会低于60 MB / s。即使SHA-256在这里显示为慢,对大多数用途也足够快。

As a point of comparison, consider that a recent hard disk will run at about 100 MB/s, and anything over USB will top below 60 MB/s. Even though SHA-256 appears "slow" here, it is fast enough for most purposes.

请注意, OpenSSL 包括一个32位的SHA-512实现,它比我的代码快得多(但不如64位SHA-512快),因为OpenSSL实现是在汇编和使用SSE2寄存器,这是不能在简单的C。SHA-512是这四个中唯一的功能,从SSE2实现受益。

Note that OpenSSL includes a 32-bit implementation of SHA-512 which is quite faster than my code (but not as fast as the 64-bit SHA-512), because the OpenSSL implementation is in assembly and uses SSE2 registers, something which cannot be done in plain C. SHA-512 is the only function among those four which benefits from a SSE2 implementation.

修改此页面,可以找到关于许多散列函数的速度的报告(点击Telechargez维护链接)。报告是法语,但它大多是表和数字,数字是国际的。实现的散列函数不包括SHA-3候选(SHABAL除外),但我正在处理它。

on this page, one can find a report on the speed of many hash functions (click on the "Telechargez maintenant" link). The report is in French, but it is mostly full of tables and numbers, and numbers are international. The implemented hash functions do not include the SHA-3 candidates (except SHABAL) but I am working on it.

这篇关于计算MD5哈希值比SHA系列函数少CPU密集度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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