Changes by: Jason J. Hickey (jyh at cs.caltech.edu)
Date: 2007-08-23 15:13:20 -0700 (Thu, 23 Aug 2007)
Revision: 12016
Log message:
Our hash was a little weak. Specifically, any sequence of text where
the characters code sum up to 6229 can be pumped without changing
the hash.
Changed this:
digest.(i) <- digest.(i) lxor (Array.unsafe_get hash_data (code + i))
To this:
digest.(i) <- (digest.(i) * 3) lxor (Array.unsafe_get hash_data (code + i))
This is from the s-box implementation at http://bretm.home.comcast.net/hash/10.html
I did some performance analysis, checking build times for omake. It is lost
in the noise at least on MacOS/Intel.
However, if performance is an issue we could to the shift and add (might be
faster than an multiply):
x <- ((x lsl 1) + x) lxor y
BTW, this topic isn't entirely random. I was working on a hash example
for the book.
Changes | Path(relative to libmojave/util) |
+2 -2 | lm_hash.ml |