Nodejs String Encrypt encrypt()

Here you can find the source of encrypt()

Method Source Code

/*// w w  w  . j  a v a  2  s .c  o m
 * Extension (uitbreiding) op het object String
 * String.encrypt(string)
 * 
 * 
 */

String.prototype.encrypt = (function () {
    // The secret table. 
    // Mappen van een karakter naar een ander : secret["a"]
    var secret = {
        'p': '\u0044' ,
        '1': 'a' ,
        '3': ':)',
        '5': '\u00A5',
        '7': '\u00C6'
    };
    
    //closure vorming = methode returnen
    return function () {
        //1. RegExp haalt elk karakter op 
        var oRegExp = /\w|\d|\s/gi;
              
        //2. asynchroon met string.replace(searchvalue,newvalue) 
        return this.replace(oRegExp, function (a) { //this is String
            return typeof (secret[a.toLowerCase()]) !== "undefined" ? secret[a.toLowerCase()]: a;
        });
    };
})();

Related

  1. encrypt()
    String.prototype.encrypt = function(){
      var outStr = [];
      for(var i=0;i<this.length;i++){
        outStr.push(this[i].charCodeAt(0))
      return outStr.join(":");
    String.prototype.decrypt = function(){
      var temp = this.split(":");
    ...