Pure python crypto

Paul Rubin phr-n2002a at nightsong.com
Wed Apr 17 04:06:28 EDT 2002


Michael Gilfix <mgilfix at eecs.tufts.edu> writes:
>   Would anyone have any use for a pure python implementation of
> Blowfish? Or any other crypto algorithms for that matter.  As a matter
> of interest, I found myself implementing the blowfish module recently
> but was unsure if any audience would be interested. No C compiler
> is required, which is nice. Could use some testing though.

I wouldn't mind having it, but it wouldn't be THAT useful, as it
would be awfully slow, and I don't know of any important programs
to interoperate with that need Blowfish.

DES/3DES seems more important for interoperability purposes.  I coded
them in pure Python but made a mistake somewhere, so the test vectors
don't work correctly, and I never got around to debugging it.  I should
take a look at it again.

If you just want to encrypt in Python without custom C modules, after
a fair amount of experimentation the fastest way I found is to use the
SHA module in output feedback mode to generate a keystream from the
key and a random initialization string, and use the array module to
combine the keystream with the plaintext.  This works pretty well on
Un*x/Linux because the /dev/urandom device makes it easy to get the
initialization strings.  However, there's no good source of such
strings under Windows using the standard modules at the moment.




More information about the Python-list mailing list