Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #include <sstream> |
| 7 | #include "common.hpp" |
| 8 | |
| 9 | using namespace std; |
| 10 | |
| 11 | namespace ndn { |
| 12 | |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 13 | string toHex(const vector<unsigned char>& array) |
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 14 | { |
| 15 | ostringstream result; |
| 16 | result.flags(ios::hex | ios::uppercase); |
| 17 | for (unsigned int i = 0; i < array.size(); ++i) { |
| 18 | unsigned char x = array[i]; |
| 19 | if (x < 16) |
| 20 | result << '0'; |
| 21 | result << (unsigned int)x; |
| 22 | } |
| 23 | |
| 24 | return result.str(); |
| 25 | } |
| 26 | |
| 27 | } |
| 28 | |