当前位置: 首页 > 工具软件 > CLFS > 使用案例 >

clfs计算文件hash方法ClfsHashPJW

夏侯旻
2023-12-01
__int64 __fastcall ClfsHashPJW(const struct _UNICODE_STRING *str)
{
  unsigned int ret; // ebx
  PWSTR buf; // rsi
  const struct _UNICODE_STRING *strref; // rbp
  unsigned int idx; // edi
  int tmp; // ebx
  unsigned int check; // ecx

  ret = 0;
  buf = str->Buffer;
  strref = str;
  idx = 0;
  if ( str->Length & 0xFFFE )
  {
    do
    {
      tmp = 16 * ret + (unsigned __int16)RtlUpcaseUnicodeChar(*buf);
      check = tmp & 0xF0000000;
      if ( tmp & 0xF0000000 )
        tmp ^= check >> 24;
      ret = check ^ tmp;
      ++buf;
      ++idx;
    }
    while ( idx < (unsigned int)strref->Length >> 1 );
  }
  return ret;
}
c#版新增
 static uint ClfsHashPJW(string str)
        {
            uint ret = 0; // ebx
            int idx = 0;
            uint tmp; // ebx
            uint check; // ecx
            if ((str.Length & 0xFFFE) > 0)
            {
                do
                {


                    ushort chr = Char.ToUpper(str[idx]);
                    tmp = ((16 * ret) + chr);
                    check = (tmp & 0xF0000000);
                    if ((tmp & 0xF0000000) >= 0)
                    {
                        tmp ^= check >> 24;
                    }
                    ret = check ^ tmp;


                    ++idx;
                } while (idx < str.Length);
            }
            return ret;
        }
 类似资料: