diff options
Diffstat (limited to 'src/hash_method.cc')
| -rw-r--r-- | src/hash_method.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/hash_method.cc b/src/hash_method.cc new file mode 100644 index 0000000..1eee04e --- /dev/null +++ b/src/hash_method.cc @@ -0,0 +1,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; +} |
