VOID HashString(LPSTR szString, PUCHAR pHash)
{
// Hash String
sha1(pHash, (const PUCHAR)szString, strlen(szString));
}
String hash to binary hash: (szData = password as hex, dwData = length of szData)
case DT_PASSWORD:
// Password hash
ZeroMemory(pHexData, sizeof(pHexData));
for (i = 0;i < lpDataRow->dwMaxLength && dwData >= 2;i++)
{
// Copy to work buffer
pHexData[0] = szData[i << 1];
pHexData[1] = szData[(i << 1) + 1];
// Decrease length
dwData -= 2;
// Convert hex to dec
u8 = (UINT8)strtoul(pHexData, &pCheck, 16);
// Sanity check
if (pCheck != &pHexData[2]) break;
// Store to memory
((PUINT8)lpBuffer)[i] = u8;
}
break;
Binary hash to string hash:
case DT_PASSWORD:
// Password hash
Put_Buffer_Format(lpOutBuffer, "%s ", lpDataRow->szName);
for (i = 0;i < lpDataRow->dwMaxLength;i++)
{
// Store to memory
i32 = (INT32)((PUINT8)lpBuffer)[i];
// Convert dec to hex
Put_Buffer_Format(lpOutBuffer, "%02x", i32);
}
Put_Buffer(lpOutBuffer, "\r\n", 2);
break;
I hope you'll catch the idea.. it's pretty simple