NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
hex-encode.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
hex-encode.hpp
"
23
24
namespace
ndn
{
25
namespace
security
{
26
namespace
transform
{
27
28
static
const
char
H2CL
[16] = {
29
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
30
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
31
};
32
33
static
const
char
H2CU
[16] = {
34
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
35
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
36
};
37
38
HexEncode::HexEncode
(
bool
useUpperCase)
39
: m_useUpperCase(useUpperCase)
40
{
41
}
42
43
size_t
44
HexEncode::convert(
const
uint8_t* data,
size_t
dataLen)
45
{
46
setOutputBuffer
(toHex(data, dataLen));
47
return
dataLen;
48
}
49
50
unique_ptr<Transform::OBuffer>
51
HexEncode::toHex(
const
uint8_t* data,
size_t
dataLen)
52
{
53
const
char
* encodePad = (m_useUpperCase) ? H2CU : H2CL;
54
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)];
59
buf++;
60
buf[0] = encodePad[(data[i] & 0x0F)];
61
buf++;
62
}
63
return
encoded;
64
}
65
66
67
68
unique_ptr<Transform>
69
hexEncode
(
bool
useUpperCase)
70
{
71
return
make_unique<HexEncode>(useUpperCase);
72
}
73
74
}
// namespace transform
75
}
// namespace security
76
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::security::transform::hexEncode
unique_ptr< Transform > hexEncode(bool useUpperCase)
Definition:
hex-encode.cpp:69
ndn::security::transform::H2CU
static const char H2CU[16]
Definition:
hex-encode.cpp:33
websocketpp::transport::asio::socket::error::security
Catch-all error for security policy errors that don't fit in other categories.
Definition:
base.hpp:79
hex-encode.hpp
ndn::security::transform::Transform::setOutputBuffer
void setOutputBuffer(unique_ptr< OBuffer > buffer)
Set output buffer to buffer.
Definition:
transform-base.cpp:104
ndn::security::transform::H2CL
static const char H2CL[16]
Definition:
hex-encode.cpp:28
ndn::security::transform::HexEncode::HexEncode
HexEncode(bool useUpperCase=false)
Create a hex encoding module.
Definition:
hex-encode.cpp:38
transform
ndnSIM
ndn-cxx
src
security
transform
hex-encode.cpp
Generated on Thu Nov 2 2017 03:30:28 for ndnSIM by
1.8.11