summaryrefslogtreecommitdiff
path: root/src/hash_method.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /src/hash_method.cc
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in memroy.
Diffstat (limited to 'src/hash_method.cc')
-rw-r--r--src/hash_method.cc17
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;
+}