String to Base64 to Hex

Convert a string to Base64 then to Hex

by brunolm

HTML

<!-- ToBase64Hex -->
<div id="r"></div>

CSS

* { font-family: courier new; }

JavaScript

var inp = "1025";

var b64 = (inp.replace(/(..)/g, function(p1) {
    return btoa(p1);
}))
    
var hex = b64.replace(/./g, function (p1) { return p1.charCodeAt(0).toString(16); });

$("#r").html("Base64: &nbsp;&nbsp; " + b64 + "<br/>+Hex: &nbsp;&nbsp;&nbsp;&nbsp; " + hex);