Posted By

Pjotor on 04/06/10


Tagged

hex String prototype encoder decoder


Versions (?)

Hex encode & decode String prototype


 / Published in: JavaScript
 

  1. String.prototype.hexDecode = function(){var r='';for(var i=0;i<this.length;i+=2){r+=unescape('%'+this.substr(i,2));}return r;}
  2. String.prototype.hexEncode = function(){var r='';var i=0;var h;while(i<this.length){h=this.charCodeAt(i++).toString(16);while(h.length<2){h=h;}r+=h;}return r;}

Report this snippet  

You need to login to post a comment.