Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Hex32BitToBinary(HexData){
- let result = "";
- //32bit hex to string
- HexData.match(/.{1,2}/g).forEach(str => {
- result += hex2bin(str)
- });
- return result;
- }
- //Function to convert hex string to binary
- function hex2bin(hex) {
- let regEx = /^[0-9]*$/g;
- let binary = ("00000000" + (parseInt(hex, 16)).toString(2)).substr(-8);
- if (regEx.test(binary)) {
- return binary;
- } else {
- return null;
- }
- };
Add Comment
Please, Sign In to add comment