Skip to content

Instantly share code, notes, and snippets.

View hassaananjum's full-sized avatar

Hassaan Anjum hassaananjum

  • Digital Energy
  • Dubai, UAE
View GitHub Profile
#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();
}