DES encryption algorithm
phr-n2002a at nightsong.com
Mon Jan 14 12:16:36 CET 2002
jjfarling at yahoo.com writes:
> I was planning to implement a pure python DES encryption algorithm.
> 1: Has any pure python algorithm been implemented already?
I coded it but there's a bug in my implementation (doesn't pass test
vectors). I haven't gotten around to debugging it. If you want to
take a look, email me.
> 2: What would be the best method (to maximise performance) in
> implementing the high intensity bit swaping of the algorithm
> (I.e. lists , long ints?)
I used long ints but that may not have been the best way. I was
planning to switch to regular ints (makes the E expansion a little
more complicated) and benchmark it both ways. No matter what you
do, it's going to be slow. The only thing a pure Python implementation
is good for is interoperating with something that really needs DES
and doesn't encrypt high volumes.
The fastest encryption alg. I've been able to implement in Python is
using the SHA hash function as an OFB mode stream cipher. Of course
the speed comes from relying on the native code SHA implementation
in the SHA module to do the grunt work. It's something like 50x faster
than my DES code. It's about 5x faster than RC4 coded in Python.
More information about the Python-list