function strToHex(str) { let out = ''; for (let i = 0; i < str.length; i++ ) { out += zeroPad(str.charCodeAt(i).toString(16), 2); } return out; }
function hexToStr(hex) { let str = ''; for (let i = 0; i < hex.length; i += 2) { str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); } return str; }http://davekb.com/search.php?target=zeroPad