The C++ code goes as below:
Code:
# include <iostream.h>
static const char HexToAsciiValue[256][2] = { {'0','0'}, {'0','1'}, .... {'F','E'},{'F','F'} };
string CharToHex (const unsigned char* pArray, unsigned int strLen)
{
string str;
str.resize (strLen*2);
char* pszHex = &str[0];
const unsigned char* pEnd = pArray + strLen;
for (const unsigned char* pChar = pArray; pChar != pEnd; pChar++, pszHex += 2 ) {
pszHex[0] = HexToAsciiValue[*pChar][0];
pszHex[1] = HexToAsciiValue[*pChar][1];
}
return str;
}
Bookmarks