添加项目文件。

This commit is contained in:
琴心
2022-04-26 15:31:46 +08:00
parent 4f1d4343fe
commit a1b66995e4
134 changed files with 18302 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
#include "checksum.h"
inline DWORD rotl32a(DWORD x, DWORD n)
{
return (x << n) | (x >> (32 - n));
}
inline char to_lower(char c)
{
if (c >= 'A' && c <= 'Z') {
c = c - 'A' + 'a';
}
return c;
}
DWORD calc_checksum(BYTE *str, size_t buf_size, bool enable_tolower)
{
if (str == NULL) return 0;
DWORD checksum = 0;
for (size_t i = 0; i < buf_size; i++) {
checksum = rotl32a(checksum, 7);
char c = str[i];
if (enable_tolower) {
c = to_lower(c);
}
checksum ^= c;
}
return checksum;
}
DWORD calc_checksum(char *str, bool enable_tolower)
{
return calc_checksum((BYTE*)str, strlen(str), enable_tolower);
}