Merge pull request #272 from frodegill/bytearray_to_string
Utility function to convert byteArray to HEX string. Useful for printing fingerprint digests etc.
This commit is contained in:
commit
fc69321d53
@ -29,6 +29,7 @@
|
|||||||
#include "vmime/base.hpp"
|
#include "vmime/base.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
namespace vmime {
|
namespace vmime {
|
||||||
@ -52,6 +53,20 @@ public:
|
|||||||
return string(reinterpret_cast <const char*>(data), count);
|
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.
|
/** Casts a string to bytes.
|
||||||
*
|
*
|
||||||
* @param str string
|
* @param str string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user