DES encryption algorithm

Carey Evans careye at spamcop.net
Sat Jan 19 22:23:52 EST 2002


"Joshua Muskovitz" <joshm at taconic.net> writes:

> Here is a handy function for handling right shift.  Replace all occurrances
> of x >> y in your code with rshift(x, y).

Note that:

 1. Function call in Python is relatively expensive, and there are a
    lot of right shifts in DES.

 2. At least in the DES implementation I ported, all the right shifts
    were by constant amounts, so I could expand them inline to
    something like ((t >> 18) & 0x3fff).

 3. A good bit of the code was right-shifting 28-bit numbers, where
    the top bit was always zero, so no change was needed.

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/

			     Cavem canus.



More information about the Python-list mailing list