This file contains 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
#include <string.h> | |
#include <bitset> | |
#include <iostream> | |
std::string hex_to_binary(std::string hexstring){ | |
static char base16encoding_table[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; | |
std::string binstring; | |
for( int i = 0; i < hexstring.length(); i++){ | |
binstring += std::bitset<4>((int)(strchr(base16encoding_table,hexstring[i]) - base16encoding_table)).to_string(); | |
} |