hash算法出现的异常!在加70分等达人170
hash算法出现的错误!在加70分等达人170
原帖:http://topic.****.net/u/20100717/00/451b53d4-04c0-4ec2-8401-0335c1bd29b3.html
发现错误是由于使用了 toupper 而引起的;去掉后可正常编译;
STDMETHODIMP CvbWB::AddTofcc(short wUID)
{
…… 我想在这里调用 hash 函数 在这里如何调用prepareCryptTable() 和 HashString()这两个函数??
}
------解决方案--------------------
toupper 函数 要 #include <locale>
如何将
char *lpszFileName换成 BSTR *lpszFileName
原帖:http://topic.****.net/u/20100717/00/451b53d4-04c0-4ec2-8401-0335c1bd29b3.html
发现错误是由于使用了 toupper 而引起的;去掉后可正常编译;
STDMETHODIMP CvbWB::AddTofcc(short wUID)
{
…… 我想在这里调用 hash 函数 在这里如何调用prepareCryptTable() 和 HashString()这两个函数??
}
- C/C++ code
unsigned long HashString( char *lpszFileName, unsigned long dwHashType ) { unsigned char *key = (unsigned char *)lpszFileName; unsigned long seed1 = 0x7FED7FED; unsigned long seed2 = 0xEEEEEEEE; int ch; while( *key != 0 ) { ch = toupper(*key++); seed1 = cryptTable[(dwHashType << 8) + ch] ^ (seed1 + seed2); seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; } return seed1; }
------解决方案--------------------
toupper 函数 要 #include <locale>
如何将
char *lpszFileName换成 BSTR *lpszFileName
- C/C++ code
[b]BSTR& bstr = _bstr_t(lpszFileName).GetBSTR(); BSTR* pbstr = _bstr_t(lpszFileName).GetAddress();[/b]
------解决方案--------------------
unsigned long cryptTable[0x500]; 我该在类的什么地方声明?
在类的头文件中声明。
------解决方案--------------------
toupper是转成大写大函数把?自己实现不是可以吗?