From 5255fd1f36eece1cbf4000ffc3120dbcb9bf5038 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 18 Sep 2007 12:38:07 -0700 Subject: Change the token prehash function for better convergence Combining arithmetric (add) and bitwise (xor) mixing seems to give better result than either. With the new prehash function, we find a valid hash much quicker. --- tokhash.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tokhash.pl') diff --git a/tokhash.pl b/tokhash.pl index 5f1a9f4..9d5888b 100755 --- a/tokhash.pl +++ b/tokhash.pl @@ -187,8 +187,8 @@ print " const char *p = token;\n"; print "\n"; print " while ((c = *p++) != 0) {\n"; -printf " uint32_t kn1 = rot(k1,%2d) - rot(k2,%2d) + c;\n", ${$sv}[0], ${$sv}[1]; -printf " uint32_t kn2 = rot(k2,%2d) - rot(k1,%2d) + c;\n", ${$sv}[2], ${$sv}[3]; +printf " uint32_t kn1 = rot(k1,%2d)^(rot(k2,%2d) + c);\n", ${$sv}[0], ${$sv}[1]; +printf " uint32_t kn2 = rot(k2,%2d)^(rot(k1,%2d) + c);\n", ${$sv}[2], ${$sv}[3]; print " k1 = kn1; k2 = kn2;\n"; print " }\n"; print "\n"; -- cgit v1.2.3