Re: HMAC module

Bram Cohen <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
Paul Rubin wrote:

> There's a very fast SHA implementation included with OpenSSL, that
> you could compare with Python's implementation.  Type "openssl speed
> sha" to run a benchmark.  Again, there's lots of overhead for short
> strings.  "2M/sec" is uninformative unless the string length is
> specified.

Python 2.1.3 (#1, Apr 20 2002, 10:14:34)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from time import time
>>> from sha import sha
>>> x = 'a' * 2 ** 20
>>> def test():
...     t = time()
...     for i in xrange(100):
...         sha(x).digest()
...     print 100.0/(time() - t)
...
>>> test()
1.34924164806

so that's 1.35 megs/sec on megabyte size blocks.

openssl reports 3.63 megs/sec on blocks of 8k.

that's a factor of 2.7 difference. Python's sha1 is, in fact, slow.

-Bram Cohen

"Markets can remain irrational longer than you can remain solvent"
                                        -- John Maynard Keynes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.