Equivalent of Javascript Bitwise Operators

Michael Foord fuzzyman at gmail.com
Wed Oct 27 13:04:36 CEST 2004

Please pardon my ignorance on this one - but I'm not certain how the
sign bt is treated in python bitwise operators. I've trying to convert
a javascript DES encryption routine into python.

Javascritp has >>> and >>. >>> is a zero fill bit shift whereas >> is
a sign propagating bit shift. My understanding is that the python >>
is equivalent to the javascript >> - but python has no equivalent to

Would a >>> 3 in javascript be equivalent to abs(a) >> 3 in python
(make sure the sign bit is set to zero first) ?

In actual fact I'm now using DES3 from Pycrypto - but I'm still
interested in the answer to the question. In case anyone is interested
I've done some work with some Javascript encryption and python
equivalents. Thsi allows you to build client side encryption into
webpages - e.g. for secure logins. It all works - very nice.


http://www.voidspace.org.uk /atlantibots/pythonutils.html

More information about the Python-list mailing list