blob: 498abe11a5e9f48fbdbf1cc9c852af7d73a3ce38 [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 Thompson1656e6a2013-08-29 18:01:48 -070014string toHex(const vector<unsigned char>& array)
Jeff Thompsona8d7b062013-08-08 15:56:35 -070015{
Jeff Thompsonb0948a52013-09-12 14:38:26 -070016 if (!&array)
17 return "";
18
Jeff Thompsona8d7b062013-08-08 15:56:35 -070019 ostringstream result;
20 result.flags(ios::hex | ios::uppercase);
21 for (unsigned int i = 0; i < array.size(); ++i) {
22 unsigned char x = array[i];
23 if (x < 16)
24 result << '0';
25 result << (unsigned int)x;
26 }
27
28 return result.str();
29}
30
31}
32