<分区>
Any easy-to-use hash function in Win32 to hash an ASCII string?
我正在 Windows 中寻找一个简单的散列函数(最好是 kernel32.dll
或其他一些广泛使用的 DLL)来将 ASCII 字符串散列成例如 DWORD
'是吗?
该函数应该从 C/C++ 或 x86 汇编中调用。
我一直在谷歌搜索,但似乎没有适合我需求的功能?
有什么建议吗?
<分区>
Any easy-to-use hash function in Win32 to hash an ASCII string?
我正在 Windows 中寻找一个简单的散列函数(最好是 kernel32.dll
或其他一些广泛使用的 DLL)来将 ASCII 字符串散列成例如 DWORD
'是吗?
该函数应该从 C/C++ 或 x86 汇编中调用。
我一直在谷歌搜索,但似乎没有适合我需求的功能?
有什么建议吗?
最佳答案
这里是示例程序,演示了 Shlwapi.dll
中 HashData
函数的使用。
这个函数非常简单和灵活(无论是输入还是输出)。
它基本上执行消息摘要。
#include <stdio.h>
#include <Shlwapi.h>
using namespace std;
#define HASH_LEN 32
int main(int argc, char* argv[])
{
const char* data = "foobarbaz";
unsigned char hash[HASH_LEN] = {0};
HashData((LPBYTE)data, strlen(data),(LPBYTE)hash, HASH_LEN);
printf("Hash: ");
for (int i = 0; i < HASH_LEN; i++) {
printf("%d ", hash[i]);
}
printf("\n");
return 0;
}
关于c++ - Win32 中任何易于使用的散列函数来散列 ASCII 字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40906079/