blob: 3a00593b500198c7c0acdaf9b741d9776eeecb0b [file] [log] [blame]
Jeff Thompsona8d7b062013-08-08 15:56:35 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
4 */
5
6#include <sstream>
7#include "common.hpp"
8
9using namespace std;
10
11namespace ndn {
12
Jeff Thompson1656e6a2013-08-29 18:01:48 -070013string toHex(const vector<unsigned char>& array)
Jeff Thompsona8d7b062013-08-08 15:56:35 -070014{
Jeff Thompsonb0948a52013-09-12 14:38:26 -070015 if (!&array)
16 return "";
17
Jeff Thompsona8d7b062013-08-08 15:56:35 -070018 ostringstream result;
19 result.flags(ios::hex | ios::uppercase);
20 for (unsigned int i = 0; i < array.size(); ++i) {
21 unsigned char x = array[i];
22 if (x < 16)
23 result << '0';
24 result << (unsigned int)x;
25 }
26
27 return result.str();
28}
29
30}
31