blob: d1c55f304f35ecf59f9acd79f7482fc41b07ef21 [file] [log] [blame]
Jeff Thompsona8d7b062013-08-08 15:56:35 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompsona8d7b062013-08-08 15:56:35 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#include <sstream>
8#include "common.hpp"
9
10using namespace std;
11
12namespace ndn {
13
Jeff Thompson0050abe2013-09-17 12:50:25 -070014string
15toHex(const vector<unsigned char>& array)
Jeff Thompsona8d7b062013-08-08 15:56:35 -070016{
Jeff Thompsonb0948a52013-09-12 14:38:26 -070017 if (!&array)
18 return "";
19
Jeff Thompsona8d7b062013-08-08 15:56:35 -070020 ostringstream result;
21 result.flags(ios::hex | ios::uppercase);
22 for (unsigned int i = 0; i < array.size(); ++i) {
23 unsigned char x = array[i];
24 if (x < 16)
25 result << '0';
26 result << (unsigned int)x;
27 }
28
29 return result.str();
30}
31
32}
33