Some of you only use BASIC, or some other language with no shift or xor instruction, so none of this will have been useful. Initialize an array like this:

  -- use an array of 256 1-byte values
  ub1 x[0..255];

  -- fill it with the values 0 to 255 in some pseudorandom order
  -- (this is derived from the alleged RC4)
  { for i in 0..255 do
    { x[i] := i;
  { for j in 0..3 do
    { for i in 0..255 do
      { s = x[i];
        k = (k + s) mod 256;
        x[i] = x[k];
        x[k] = s;
And then use the array for hashing like this:
  -- use the length of the message to initialize the hash
  -- XXX can be 0, or some constant, or some argument
  hash := (XXX+len) mod 256;

  -- hash the characters in the message one byte at a time
  {for i in 0..len-1 do
    {hash := (hash + message[i]) mod 256;  hash := x[hash];}}
This is known as Pearson's hash, I think it was in the June 1990 issue of Communications of the ACM. See, no shifts or XORs. It is somewhat similar to RC4, a (very proprietary) random number generator owned(?) by RSA Security.

Hash functions and block ciphers

Oracle SQL tricks

Table of Contents