Changeset 675
- Timestamp:
- 01/30/12 22:26:32 (16 months ago)
- Location:
- trollforge/lastmeasure/server
- Files:
-
- 2 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trollforge/lastmeasure/server/lmutil.h
r673 r675 11 11 #include <time.h> /* localtime_r() */ 12 12 13 #include "md5.h"13 //#include "md5.h" 14 14 #include "lmkeywords.h" 15 16 /* Jacked from http://lol.zoy.org/blog/2011/12/20/cpp-constant-string-hash */ 17 /* max heartiez to sam */ 18 #define H1(s,i,x) (x*65599u+(uint8_t)s[(i)<strlen(s)?strlen(s)-1-(i):strlen(s)]) 19 #define H4(s,i,x) H1(s,i,H1(s,i+1,H1(s,i+2,H1(s,i+3,x)))) 20 #define H16(s,i,x) H4(s,i,H4(s,i+4,H4(s,i+8,H4(s,i+12,x)))) 21 #define H64(s,i,x) H16(s,i,H16(s,i+16,H16(s,i+32,H16(s,i+48,x)))) 22 #define H256(s,i,x) H64(s,i,H64(s,i+64,H64(s,i+128,H64(s,i+192,x)))) 23 24 #define HASH(s) ((uint32_t)(H256(s,0,0)^(H256(s,0,0)>>16))) 15 25 16 26 class Random … … 129 139 char buffer[16]; 130 140 char iphash[37]; 131 char hash[8];141 unsigned int hash; 132 142 133 143 sprintf(iphash,"%s%d",client_ip,rand()%32767); 134 144 135 md5((unsigned char*)iphash,8,(unsigned char*)hash);145 hash = HASH(iphash); 136 146 137 147 sprintf(buffer, "%lx", (0xffffffff - t)); 138 strcat(buffer, hash);148 strcat(buffer,(char const *)hash); 139 149 140 150 return buffer;
Note: See TracChangeset
for help on using the changeset viewer.
