Description: The header 'boost/algorithm/hex.hpp'contains the algorithm hex() and unhex() in C++ boost library. These functions are designed based on the MySQL function HEX and UNHEX. These functions are used for converting characters to hexadecimal values or hexadecimal to characters.
Parameters: The following parameters are accepted by the function: 1.) range: It is the iterator set for entire range of sequence.
2.) output iterator: It is the iterator set for copying the resultant value in hexadecimal or vice-versa.
intmain() { vector<int> Arr = {168734875}; /* Passing integer vector Arr to the hex function, ** this function expects an iterator to write the ** resultant hexadecimal value, so we attached ** output stream iterator to directly print the value */ boost::algorithm::hex(Arr, ostream_iterator<char> {cout, ""});
/* We passed hexadecimal value which will be interpreted as ASCII Code */ string s = "6370702073656372657473"; cout << endl << boost::algorithm::unhex(s); }
Example: Output: 0A0EB09B cpp secrets
Please write on comment section if you find any mistake or for any suggestions.
Comments