28 static const char H2CL[16] = {
29 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
30 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 33 static const char H2CU[16] = {
34 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
35 '8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' 39 : m_useUpperCase(useUpperCase)
44 HexEncode::convert(
const uint8_t* data,
size_t dataLen)
50 unique_ptr<Transform::OBuffer>
51 HexEncode::toHex(
const uint8_t* data,
size_t dataLen)
53 const char* encodePad = (m_useUpperCase) ? H2CU : H2CL;
55 auto encoded = make_unique<OBuffer>(dataLen * 2);
56 uint8_t* buf = &encoded->front();
57 for (
size_t i = 0; i < dataLen; i++) {
58 buf[0] = encodePad[((data[i] >> 4) & 0x0F)];
60 buf[0] = encodePad[(data[i] & 0x0F)];
71 return make_unique<HexEncode>(useUpperCase);
Copyright (c) 2013-2017 Regents of the University of California.