Blowfish in Python?

Markus Stenberg mstenber at cc.Helsinki.FI
Sun Feb 27 04:28:20 EST 2000


(And no, I'm not talking about real fishes being eaten by Pythons here)

I spent few hours last weekend implementing Blowfish block encryption
algorithm in Python (and several digest algorithms and other stuff, but
that's not the point). 

In digest algorithms, speed was horrible, but I expected it to be; I didn't
really mind it. In Blowfish, however, on ia-32 platform and tolerably fast
CPU, speed was horrendous. 

I think the main reason was the fact that I had to use _long ints_ for
calculations, as the normal ints are signed, and apparently the bitwise
operators do not work as advertised when bit32 is set (=number is
negative). Or that's my theory anyway - my implementation worked with
long's and did not work with ints.

But I'm digressing. The query I was intending to ask was this:

Has anyone actually succeeded in producing a _fast_ pure-Python Blowfish
implementation? C implementations routinely go to megabytes/second level;
my Python-with-longs implementation was kilobytes/second, to be precise,
2-10k/s depending on the machine.

For this application to be feasible, there cannot be any C-modules, so you
can forget about "write it in C and use extension module" or "use that
module <foo>, it's implemented in C, dummy!". I have done both in past, but
this should be _very_ portable implementation, and partially on platforms I
don't even have compiler on.

-Markus

-- 
     /\  	       	       	    			     /\
    /()\          .. Something _is_ out there ..            /()\
   /____\						   /____\
[Not neccessarily anything as friendly as the Illuminati, either ;)]



More information about the Python-list mailing list