diff options
author | Frode Roxrud Gill <[email protected]> | 2022-03-13 10:59:02 +0000 |
---|---|---|
committer | Frode Roxrud Gill <[email protected]> | 2022-03-13 10:59:02 +0000 |
commit | 6fd36329127c9fc88019e47e6d4840e8b26e8d64 (patch) | |
tree | 56aff7aafcb07ad1a6683c11adf1242d0417518c /src | |
parent | Merge pull request #1 from frodegill/digest_sha256 (diff) | |
download | vmime-6fd36329127c9fc88019e47e6d4840e8b26e8d64.tar.gz vmime-6fd36329127c9fc88019e47e6d4840e8b26e8d64.zip |
Added utility function to convert byteArray to HEX string. Useful for printing fingerprint digests etc.
Diffstat (limited to 'src')
-rw-r--r-- | src/vmime/utility/stringUtils.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vmime/utility/stringUtils.hpp b/src/vmime/utility/stringUtils.hpp index 46789406..a4b05ec3 100644 --- a/src/vmime/utility/stringUtils.hpp +++ b/src/vmime/utility/stringUtils.hpp @@ -29,6 +29,7 @@ #include "vmime/base.hpp" #include <sstream> +#include <iostream> namespace vmime { @@ -52,6 +53,20 @@ public: return string(reinterpret_cast <const char*>(data), count); } + /** Makes a HEX string from byteArray. + * + * @param data byteArray containing data + * @return a string object containing a hex copy of the specified data + */ + static const string makeHexStringFromBytes(const byteArray& data) { + std::stringstream ss; + for (const byte_t& b : data) + { + ss << std::hex << int(b); + } + return ss.str(); + } + /** Casts a string to bytes. * * @param str string |