Closed Moriarty2016 closed 6 years ago
I pick out the hash calculation snippet from FunctionTest.cpp, and recreate a project with it, code as below:
DWORD HashFunctionName(LPSTR name) { DWORD hash = 0;
do { hash = ROTR32(hash, 13); hash += *name; name++; } while (*(name - 1) != 0); return hash;
}
int main(int argc, char **argv) { if (argc == 2) { printf("0x%x\n", HashFunctionName(argv[1])); } return 0; }
The output is clearly not right, what's wrong?
Problem solved, My fault:-)
I pick out the hash calculation snippet from FunctionTest.cpp, and recreate a project with it, code as below:
include "stdafx.h"
include
define ROTR32(value, shift) (((DWORD) value >> (BYTE) shift) | ((DWORD) value << (32 - (BYTE) shift)))
DWORD HashFunctionName(LPSTR name) { DWORD hash = 0;
}
int main(int argc, char **argv) { if (argc == 2) { printf("0x%x\n", HashFunctionName(argv[1])); } return 0; }
The output is clearly not right, what's wrong?