Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string to_hex(const void *data, const unsigned int size) {
- std::stringstream stream;
- stream << std::uppercase << std::hex;
- const unsigned char *bytes = static_cast<const unsigned char *>(data);
- for (unsigned int i = 0; i<size; ++i) {
- stream << std::setfill('0') << std::setw(2) << static_cast<const int>(bytes[i]) << " ";
- }
- return stream.str().substr(0, stream.str().size()-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement