Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <iomanip>
- using namespace std;
- char * HexConvert(char* message,int lenght){
- ostringstream str;
- for (int i = 0; i < (lenght-1); i++){
- str << hex << setw(2) << setfill('0') << (int)((unsigned char)message[i]);
- }
- str << '\x00';
- auto ret = new char [(lenght * 2)+1];
- strncpy_s(ret,(lenght*2)+1, (char*)str.str().c_str(), (lenght * 2) + 1);
- return ret;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- cout << HexConvert("\xff\x00", 3)<<endl;
- system("PAUSE>NUL");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement