daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Hex32BitToBinary(HexData){
  2.   let result = "";
  3.   //32bit hex to string
  4.   HexData.match(/.{1,2}/g).forEach(str => {
  5.     result += hex2bin(str)
  6.   });
  7.   return result;
  8. }
  9.  
  10. //Function to convert hex string to binary
  11. function hex2bin(hex) {
  12.   let regEx = /^[0-9]*$/g;
  13.   let binary = ("00000000" + (parseInt(hex, 16)).toString(2)).substr(-8);
  14.   if (regEx.test(binary)) {
  15.     return binary;
  16.   } else {
  17.     return null;
  18.   }
  19. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top