Nodejs String from Hex fromHex()

Here you can find the source of fromHex()

Method Source Code

/**//from   ww  w. j  a  v a2 s.  com
 * Convert a hex bitstring into the string it represents. (For reading output
 * from CryptoJS.) The underlying string is not modified.
 */
String.prototype.fromHex = String.prototype.fromHex || function () {
    var len = this.length/2,
        ret = new Array(len);

    for (var i = 0; i < len; i++) {
        ret[i] = parseInt('0x' + this[2*i] + this[2*i+1]);
    }

    return String.fromCharCode.apply(this,ret);
};

Related

  1. fromHex()
    String.prototype.fromHex = function() {
      for (var hex = this.split(' '), i = 0, $ = '', h; h = hex[i]; i++) $ += String.fromCharCode(parseInt(h, 16));
      return $;
    };