Function to parse Base64 data and display it as a hex viewer function hexViewer base64Data Decode Base64 to a binary string const binaryStr atob base64Data Convert binary string to byte array const bytes new Uint8Array binaryStr length for let i 0 i binaryStr length i bytes i binaryStr charCodeAt i Build the hex viewer display let output for let i 0 i bytes length i 16 Address offset column output 00000000 i toString 16 slice 8 Hex values column for let j 0 j 16 j if i j bytes length output 00 bytes i j toString 16 slice 2 toUpperCase else output ASCII values column output for let j 0 j 16 j if i j bytes length const charCode bytes i j output charCode 32 charCode 126 String fromCharCode charCode output n console log output Example usage const base64Data SGVsbG8gV29ybGQh Hello World in Base64 hexViewer base64Data document body style minHeight 600px Function to parse Base64 data and display it as a hex viewer function hexViewer base64Data let divcontainer document createElement div document body appendChild divcontainer Decode Base64 to a binary string const binaryStr atob base64Data Convert binary string to byte array const bytes new Uint8Array binaryStr length for let i 0 i binaryStr length i bytes i binaryStr charCodeAt i Build the hex viewer display let output for let i 0 i bytes length i 16 Address offset column const addr 00000000 i toString 16 slice 8 let hex Hex values column for let j 0 j 16 j if i j bytes length hex 00 bytes i j toString 16 slice 2 toUpperCase else hex ASCII values column let str for let j 0 j 16 j if i j bytes length const charCode bytes i j str charCode 32 charCode 126 String fromCharCode charCode output n output tr td style background color white addr td td style background color yellow hex td td style background color orange str td tr let div document createElement div divcontainer appendChild div div innerHTML table output table Example usage const base64Data SGVsbG8gV29ybGQh9392bba39282babcdef Hello World in Base64 hexViewer base64Data
tring const binaryStr atob base64Data Convert binary string to byte array const bytes new Uint8Array binaryStr length for let i 0 i binaryStr length i bytes i binaryStr charCodeAt i Build the hex viewer display let output for let i 0 i bytes length i 16 Address offset column const addr 00000000 i toString 16 slice 8 let hex Hex values column for let j 0 j 16 j if i j bytes length hex 00 bytes i j toString 16 slice 2 toUpperCase else hex ASCII values column let str for let j 0 j 16 j if i j bytes length const charCode bytes i j str charCode 32 charCode 126 String fromCharCode charCode output n output tr td style background color white addr td td style background color yellow hex td td style background color orange str td tr let div document createElement div divcontainer appendChild div div innerHTML table output table Example usage const base64Data SGVsbG8gV29ybGQh9392bba39282babcdef Hello World in Base64 hexViewer base64Data