From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- src/hash_method.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/hash_method.cc (limited to 'src/hash_method.cc') 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; +} -- cgit v1.2.3-70-g09d2