This Javascript MD5 implementation confused me.
In global space, the author declares var:
var hexcase = 0;
Next, the following method will appear:
function rstr2hex(input) { try { hexcase } catch(e) { hexcase=0; } var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var output = ""; var x; for(var i = 0; i < input.length; i++) { x = input.charCodeAt(i); output += hex_tab.charAt((x >>> 4) & 0x0F) + hex_tab.charAt( x & 0x0F); } return output; }
The line that I do not understand is:
try { hexcase } catch(e) { hexcase=0; }
What is the author trying to do here?
Steve source share