Bool CWHEncrypt: : XorEncrypt (LPCTSTR pszSourceData, LPTSTR pszEncrypData, WORD wMaxCount)
{
//variable definition
CT2CW strSrcData (pszSourceData);
WCHAR szEncrypData [MAX_ENCRYPT_LEN + 1]=L "";
//generate keys
WORD wRandKey [ENCRYPT_KEY_LEN];
WRandKey [0]=lstrlenW (strSrcData);
For (WORD I=1; i
//steps to prepare
WORD wTempCode=0;
WORD wTimes=((wRandKey ENCRYPT_KEY_LEN [0] + 1)/ENCRYPT_KEY_LEN) * ENCRYPT_KEY_LEN;
//parameters come
ASSERT ((wTimes * 8 + 1) & lt;=wMaxCount);
If ((wTimes * 8 + 1) & gt; WMaxCount) return false.
//generated ciphertext
For (WORD I=0; i
If (i
Swprintf (szEncrypData + I * 8, L "% % 4 x 4 x", wRandKey ENCRYPT_KEY_LEN] [I %, wTempCode);
}
//character conversion
CW2CT strEncrypData (szEncrypData);
Lstrcpyn (pszEncrypData strEncrypData, wMaxCount);
return true;
}
//unlock ciphertext
Bool CWHEncrypt: : XorCrevasse (LPCTSTR pszEncrypData, LPTSTR pszSourceData, WORD wMaxCount)
{
//set the results
PszSourceData [0]=0;
//variable definition
CT2CW strEncrypData (pszEncrypData);
WCHAR szSrcData [MAX_SOURCE_LEN]=L "";
//efficacy length
WORD wEncrypPassLen=lstrlenW (strEncrypData);
If (wEncrypPassLen
//extraction length
WCHAR szTempBuffer [5]=L "";
SzTempBuffer [CountArray (szTempBuffer) - 1)=0.
CopyMemory (szTempBuffer, LPCWSTR strEncrypData, sizeof (WCHAR) * 4);
//get length
WCHAR * pEnd=NULL;
WORD wSoureLength=(WORD) wcstol (szTempBuffer, & amp; PEnd, 16);
//length efficacy
ASSERT (wEncrypPassLen==(((wSoureLength + ENCRYPT_KEY_LEN - 1)/ENCRYPT_KEY_LEN) * ENCRYPT_KEY_LEN * 8));
If (wEncrypPassLen!=(((wSoureLength + ENCRYPT_KEY_LEN - 1)/ENCRYPT_KEY_LEN) * ENCRYPT_KEY_LEN * 8)) return false.
//length efficacy
ASSERT (+ 1) (wSoureLength & lt;=wMaxCount);
If ((wSoureLength + 1) & gt; WMaxCount) return false.
//unlock password
For (INT I=0; i
//get key
WCHAR szKeyBuffer [5].
SzKeyBuffer [CountArray (szKeyBuffer) - 1)=0.
SzTempBuffer [CountArray (szTempBuffer) - 1)=0.
CopyMemory (szKeyBuffer, (LPCWSTR) (strEncrypData + I * 8), sizeof (WCHAR) * 4);
CopyMemory (szTempBuffer, LPCWSTR strEncrypData + I * 8 + 4, sizeof (WCHAR) * 4);
//to extract the key
WCHAR wKey=(WCHAR) wcstol (szKeyBuffer, & amp; PEnd, 16);
WCHAR wEncrypt=(WCHAR) wcstol (szTempBuffer, & amp; PEnd, 16);
//generated the original
SzSrcData [I]=(WCHAR) ((WCHAR) wKey ^ (WCHAR) wEncrypt);
}
//terminate the characters
SzSrcData [wSoureLength]=0;
//character conversion
CW2CT strSrcData (szSrcData);
Lstrcpyn (pszSourceData strSrcData, wMaxCount);
return true;
}
===================================================================
//machine id
Bool CWHService: : GetMachineID (TCHAR szMachineID [LEN_MACHINE_ID])
{
//variable definition
TCHAR szMACAddress [LEN_NETWORK_ID]=TEXT (" ");
//network card id
GetMACAddress (szMACAddress);
//conversion information
ASSERT (LEN_MACHINE_ID & gt;=LEN_MD5);
CWHEncrypt: : MD5Encrypt (szMACAddress szMachineID);
return true;
}
//machine id
Bool CWHService: : GetMachineIDEx (TCHAR szMachineID [LEN_MACHINE_ID])
{
//variable definition
TCHAR szMACAddress [LEN_NETWORK_ID]=TEXT (" ");
//network card id
WORD wMacSize=GetMACAddress (szMACAddress);
//hard disk logo
DWORD * pbufs=(DWORD *) szMACAddress;
The WORD wIndex=(wMacSize + sizeof (DWORD) - 1)/sizeof (DWORD);
LPCTSTR pszHardDisk []={TEXT (" C: \ \ "), TEXT (" D: \ \ "), TEXT (" E: \ \ ")};
For (WORD I=wIndex; i
ASSERT (CountArray (pszHardDisk) & gt; (I - wIndex));
GetVolumeInformation (pszHardDisk [I - wIndex], NULL, 0, pbufs + I, NULL, NULL, 0, NULL);
}
//conversion information
ASSERT (LEN_MACHINE_ID & gt;=LEN_MD5);
CWHEncrypt: : MD5Encrypt (szMACAddress szMachineID);
return true;
}
==============================================
Wish you a great god help me to convert the DELPHI thank you