function StringToHexString(str) { var retval = ""; var cbdata = str.length; if(cbdata > 0) { var i = 0; while(cbdata--) { var b = (str.charCodeAt(i) & 0xF0) >> 4; retval += (b <= 9) ? String.fromCharCode(b + 48) : String.fromCharCode((b - 10) + 65); b = str.charCodeAt(i) & 0x0F; retval += (b <= 9) ? String.fromCharCode(b + 48) : String.fromCharCode((b - 10) + 65); i++; } } return retval; }