[PYTHON-CRYPTO] HMAC module
Bram Cohen
bram at GAWTH.COM
Thu May 30 21:06:09 CEST 2002
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
More information about the python-crypto
mailing list