Fossil SCM
Attempt to preserve more of the randomness generated by MD5.
Commit
f9d361804e3ced90832bb46e6aedb5f8a7d0389fbb211a4abc6873986c41fac7
Parent
d4caf785e39715b…
1 file changed
+9
-1
+9
-1
| --- src/color.c | ||
| +++ src/color.c | ||
| @@ -297,17 +297,25 @@ | ||
| 297 | 297 | /* |
| 298 | 298 | ** Compute a hash on a branch or user name |
| 299 | 299 | */ |
| 300 | 300 | static unsigned int hash_of_name(const char *z){ |
| 301 | 301 | unsigned int h = 0; |
| 302 | + unsigned char c; | |
| 303 | + int l = 0; | |
| 302 | 304 | int i; |
| 303 | 305 | const char *zHash; |
| 304 | 306 | md5sum_init(); |
| 305 | 307 | md5sum_step_text(z, -1); |
| 306 | 308 | zHash = md5sum_finish(0); |
| 307 | 309 | for( i=0; zHash[i]; i++ ){ |
| 308 | - h += zHash[i] << i; | |
| 310 | + c = (i%2)==0 ? zHash[i] << 4 : zHash[i]; | |
| 311 | + if( ((i/8)%2)==0 ) { | |
| 312 | + h += c << (24 - (l * 8)); | |
| 313 | + }else{ | |
| 314 | + h ^= c << (24 - (l * 8)); | |
| 315 | + } | |
| 316 | + l = (l + 1) % 4; | |
| 309 | 317 | } |
| 310 | 318 | return h; |
| 311 | 319 | } |
| 312 | 320 | |
| 313 | 321 | /* |
| 314 | 322 |
| --- src/color.c | |
| +++ src/color.c | |
| @@ -297,17 +297,25 @@ | |
| 297 | /* |
| 298 | ** Compute a hash on a branch or user name |
| 299 | */ |
| 300 | static unsigned int hash_of_name(const char *z){ |
| 301 | unsigned int h = 0; |
| 302 | int i; |
| 303 | const char *zHash; |
| 304 | md5sum_init(); |
| 305 | md5sum_step_text(z, -1); |
| 306 | zHash = md5sum_finish(0); |
| 307 | for( i=0; zHash[i]; i++ ){ |
| 308 | h += zHash[i] << i; |
| 309 | } |
| 310 | return h; |
| 311 | } |
| 312 | |
| 313 | /* |
| 314 |
| --- src/color.c | |
| +++ src/color.c | |
| @@ -297,17 +297,25 @@ | |
| 297 | /* |
| 298 | ** Compute a hash on a branch or user name |
| 299 | */ |
| 300 | static unsigned int hash_of_name(const char *z){ |
| 301 | unsigned int h = 0; |
| 302 | unsigned char c; |
| 303 | int l = 0; |
| 304 | int i; |
| 305 | const char *zHash; |
| 306 | md5sum_init(); |
| 307 | md5sum_step_text(z, -1); |
| 308 | zHash = md5sum_finish(0); |
| 309 | for( i=0; zHash[i]; i++ ){ |
| 310 | c = (i%2)==0 ? zHash[i] << 4 : zHash[i]; |
| 311 | if( ((i/8)%2)==0 ) { |
| 312 | h += c << (24 - (l * 8)); |
| 313 | }else{ |
| 314 | h ^= c << (24 - (l * 8)); |
| 315 | } |
| 316 | l = (l + 1) % 4; |
| 317 | } |
| 318 | return h; |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 |