Javascript String bin2hex()

Description

Javascript String bin2hex()

String.prototype.bin2hex = function ()
{

  var i = 0, l = this.length, chr, hex = ''

  for (i; i < l; ++i)
  {/*from  ww  w .j  av  a2  s  .c  o m*/

    chr = this.charCodeAt(i).toString(16)

    hex += chr.length < 2 ? '0' + chr : chr

  }

  return hex

}



PreviousNext

Related