Skip to content

Instantly share code, notes, and snippets.

@PeterHajdu
Created September 11, 2010 12:23
Show Gist options
  • Save PeterHajdu/575147 to your computer and use it in GitHub Desktop.
Save PeterHajdu/575147 to your computer and use it in GitHub Desktop.
Some bitmagic in c++.
#include <iomanip>
#include <string>
#include <sstream>
std::string
hexDump( const unsigned char * data, unsigned int length )
{
std::stringstream ret;
for ( unsigned int i = 0; i < length; ++i )
{
ret << std::hex << static_cast< unsigned int >( data[i] ) << std::setfill('0') << std::setw(2);
}
return ret.str();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment