summaryrefslogtreecommitdiff
path: root/src/hash_method.cc
blob: 1eee04e68122d09d8222b917163020ca5215985b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "common.hh"

#include "hash_method.hh"

std::string HashMethod::to_string(uint8_t const* data, size_t len) {
  static const char kChar[] = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'a', 'b', 'c', 'd', 'e', 'f'
  };
  std::string ret;
  ret.reserve(len * 2);
  for (size_t i = 0; i < len; ++i) {
    ret.push_back(kChar[data[i] >> 4]);
    ret.push_back(kChar[data[i] & 0xf]);
  }
  return ret;
}