[plt-scheme] BitField

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat Nov 2 09:48:15 EST 2002

Paulo Jorge O. C. Matos wrote:

> I have to check out your references. No, I saw the bitwise operations 
> but I also tried to implemented SHA-1 hashing algorithm that uses alot 
> of shifts, etc. How do you manage to do a shift with the bitwise 
> operations available?

Shifting is done with arithmetic-shift.

Rotation is done like this:

/(define (word<<< n s)
//  (bitwise-ior (arithmetic-shift n s) 
//               (arithmetic-shift n (- s 32))))/

The <<< notation was chosen in order to mimic the notation of the MD5 RFC.

Jens Axel Søgaard

Posted on the users mailing list.