Last active
June 1, 2016 02:56
-
-
Save rikioy/070d94207e90ce77c1e6455d27609d41 to your computer and use it in GitHub Desktop.
bin2hex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::string bin2hex(const std::string& input) | |
| { | |
| std::string res; | |
| const char hex[] = "0123456789ABCDEF"; | |
| for(unsigned int i = 0; i < input.size(); i++) | |
| { | |
| char sc = input[i]; | |
| unsigned char c = static_cast<unsigned char>(sc); | |
| res += hex[c >> 4]; | |
| res += hex[c & 0xf]; | |
| } | |
| return res; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NB