At one point I needed to encode a string in hexadecimal representation in order to perform a coding tasks. JavaScript function that does this is:
function encodeToHex(str) {
var result = "";
for (var i = 0; i < str.length; i++) {
result += str.charCodeAt(i).toString(16);
}
return result;
}