-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStrConversion.h
42 lines (33 loc) · 1.12 KB
/
StrConversion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/////////////////////////////////////////////////////////////////////////////
// StrConversion.h
//
// Copyright (C) 2009 Ideas of East Ltd. All Rights Reserved.
// http://www.ideasofeast.com
// info@ideasofeast.com
//
// Developers:
// Veria Kalantari, veria@ideasofeast.com
//
#ifndef STRING_CONVERSION_INCLUDED
#define STRING_CONVERSION_INCLUDED
#pragma once
#include <windows.h>
#include <ctype.h>
namespace StrConversion
{
#define BASE16SYM ("0123456789ABCDEF")
#define BASE16VAL ("\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9:;<=>?@\xA\xB\xC\xD\xE\xF")
#define BASE16_ENCODELO(b) (BASE16SYM[((unsigned char)(b)) >> 4])
#define BASE16_ENCODEHI(b) (BASE16SYM[((unsigned char)(b)) & 0xF])
#define BASE16_DECODELO(b) (BASE16VAL[toupper(b) - '0'] << 4)
#define BASE16_DECODEHI(b) (BASE16VAL[toupper(b) - '0'])
class CStrConverter
{
public:
CStrConverter(void);
~CStrConverter(void);
void HexStrToByteArray(const char *lpHexStr, unsigned char **lppByteArray, unsigned int *lpnBuffSize);
void ByteArrayToHexStr(const unsigned char *lpByteArray, unsigned int nBuffSize, char **lppHexStr);
};
}
#endif