Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/Simple-WebSocket-Server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreidheim <eidheim@gmail.com>2016-12-20 13:44:05 +0300
committereidheim <eidheim@gmail.com>2016-12-20 13:45:52 +0300
commit7ce16e8e0aa8a7ddc887939dcccefa29e665b97c (patch)
tree754473125802db5133f19ef59168b08dff445931 /crypto.hpp
parentb13ae3f997b6f9e2ae041efe7a1bb88eb581f012 (diff)
Added Crypto::to_hex_string
Diffstat (limited to 'crypto.hpp')
-rw-r--r--crypto.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto.hpp b/crypto.hpp
index e1648d2..0785b5f 100644
--- a/crypto.hpp
+++ b/crypto.hpp
@@ -3,6 +3,8 @@
#include <string>
#include <cmath>
+#include <sstream>
+#include <iomanip>
//Moving these to a seperate namespace for minimal global namespace cluttering does not work with clang++
#include <openssl/evp.h>
@@ -75,6 +77,15 @@ namespace SimpleWeb {
}
};
+ /// Return hex string from bytes in input string.
+ static std::string to_hex_string(const std::string &input) {
+ std::stringstream hex_stream;
+ hex_stream << std::hex << std::internal << std::setfill('0');
+ for (auto &byte : input)
+ hex_stream << std::setw(2) << (int)(unsigned char)byte;
+ return hex_stream.str();
+ }
+
static std::string MD5(const std::string &input, size_t iterations=1) {
std::string hash;