github.com/Gessiux/neatchain@v1.3.1/internal/jsre/deps/web3.js (about)

     1  require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
     2  module.exports=[
     3    {
     4      "constant": true,
     5      "inputs": [
     6        {
     7          "name": "_owner",
     8          "type": "address"
     9        }
    10      ],
    11      "name": "name",
    12      "outputs": [
    13        {
    14          "name": "o_name",
    15          "type": "bytes32"
    16        }
    17      ],
    18      "type": "function"
    19    },
    20    {
    21      "constant": true,
    22      "inputs": [
    23        {
    24          "name": "_name",
    25          "type": "bytes32"
    26        }
    27      ],
    28      "name": "owner",
    29      "outputs": [
    30        {
    31          "name": "",
    32          "type": "address"
    33        }
    34      ],
    35      "type": "function"
    36    },
    37    {
    38      "constant": true,
    39      "inputs": [
    40        {
    41          "name": "_name",
    42          "type": "bytes32"
    43        }
    44      ],
    45      "name": "content",
    46      "outputs": [
    47        {
    48          "name": "",
    49          "type": "bytes32"
    50        }
    51      ],
    52      "type": "function"
    53    },
    54    {
    55      "constant": true,
    56      "inputs": [
    57        {
    58          "name": "_name",
    59          "type": "bytes32"
    60        }
    61      ],
    62      "name": "addr",
    63      "outputs": [
    64        {
    65          "name": "",
    66          "type": "address"
    67        }
    68      ],
    69      "type": "function"
    70    },
    71    {
    72      "constant": false,
    73      "inputs": [
    74        {
    75          "name": "_name",
    76          "type": "bytes32"
    77        }
    78      ],
    79      "name": "reserve",
    80      "outputs": [],
    81      "type": "function"
    82    },
    83    {
    84      "constant": true,
    85      "inputs": [
    86        {
    87          "name": "_name",
    88          "type": "bytes32"
    89        }
    90      ],
    91      "name": "subRegistrar",
    92      "outputs": [
    93        {
    94          "name": "",
    95          "type": "address"
    96        }
    97      ],
    98      "type": "function"
    99    },
   100    {
   101      "constant": false,
   102      "inputs": [
   103        {
   104          "name": "_name",
   105          "type": "bytes32"
   106        },
   107        {
   108          "name": "_newOwner",
   109          "type": "address"
   110        }
   111      ],
   112      "name": "transfer",
   113      "outputs": [],
   114      "type": "function"
   115    },
   116    {
   117      "constant": false,
   118      "inputs": [
   119        {
   120          "name": "_name",
   121          "type": "bytes32"
   122        },
   123        {
   124          "name": "_registrar",
   125          "type": "address"
   126        }
   127      ],
   128      "name": "setSubRegistrar",
   129      "outputs": [],
   130      "type": "function"
   131    },
   132    {
   133      "constant": false,
   134      "inputs": [],
   135      "name": "Registrar",
   136      "outputs": [],
   137      "type": "function"
   138    },
   139    {
   140      "constant": false,
   141      "inputs": [
   142        {
   143          "name": "_name",
   144          "type": "bytes32"
   145        },
   146        {
   147          "name": "_a",
   148          "type": "address"
   149        },
   150        {
   151          "name": "_primary",
   152          "type": "bool"
   153        }
   154      ],
   155      "name": "setAddress",
   156      "outputs": [],
   157      "type": "function"
   158    },
   159    {
   160      "constant": false,
   161      "inputs": [
   162        {
   163          "name": "_name",
   164          "type": "bytes32"
   165        },
   166        {
   167          "name": "_content",
   168          "type": "bytes32"
   169        }
   170      ],
   171      "name": "setContent",
   172      "outputs": [],
   173      "type": "function"
   174    },
   175    {
   176      "constant": false,
   177      "inputs": [
   178        {
   179          "name": "_name",
   180          "type": "bytes32"
   181        }
   182      ],
   183      "name": "disown",
   184      "outputs": [],
   185      "type": "function"
   186    },
   187    {
   188      "anonymous": false,
   189      "inputs": [
   190        {
   191          "indexed": true,
   192          "name": "_name",
   193          "type": "bytes32"
   194        },
   195        {
   196          "indexed": false,
   197          "name": "_winner",
   198          "type": "address"
   199        }
   200      ],
   201      "name": "AuctionEnded",
   202      "type": "event"
   203    },
   204    {
   205      "anonymous": false,
   206      "inputs": [
   207        {
   208          "indexed": true,
   209          "name": "_name",
   210          "type": "bytes32"
   211        },
   212        {
   213          "indexed": false,
   214          "name": "_bidder",
   215          "type": "address"
   216        },
   217        {
   218          "indexed": false,
   219          "name": "_value",
   220          "type": "uint256"
   221        }
   222      ],
   223      "name": "NewBid",
   224      "type": "event"
   225    },
   226    {
   227      "anonymous": false,
   228      "inputs": [
   229        {
   230          "indexed": true,
   231          "name": "name",
   232          "type": "bytes32"
   233        }
   234      ],
   235      "name": "Changed",
   236      "type": "event"
   237    },
   238    {
   239      "anonymous": false,
   240      "inputs": [
   241        {
   242          "indexed": true,
   243          "name": "name",
   244          "type": "bytes32"
   245        },
   246        {
   247          "indexed": true,
   248          "name": "addr",
   249          "type": "address"
   250        }
   251      ],
   252      "name": "PrimaryChanged",
   253      "type": "event"
   254    }
   255  ]
   256  
   257  },{}],2:[function(require,module,exports){
   258  module.exports=[
   259    {
   260      "constant": true,
   261      "inputs": [
   262        {
   263          "name": "_name",
   264          "type": "bytes32"
   265        }
   266      ],
   267      "name": "owner",
   268      "outputs": [
   269        {
   270          "name": "",
   271          "type": "address"
   272        }
   273      ],
   274      "type": "function"
   275    },
   276    {
   277      "constant": false,
   278      "inputs": [
   279        {
   280          "name": "_name",
   281          "type": "bytes32"
   282        },
   283        {
   284          "name": "_refund",
   285          "type": "address"
   286        }
   287      ],
   288      "name": "disown",
   289      "outputs": [],
   290      "type": "function"
   291    },
   292    {
   293      "constant": true,
   294      "inputs": [
   295        {
   296          "name": "_name",
   297          "type": "bytes32"
   298        }
   299      ],
   300      "name": "addr",
   301      "outputs": [
   302        {
   303          "name": "",
   304          "type": "address"
   305        }
   306      ],
   307      "type": "function"
   308    },
   309    {
   310      "constant": false,
   311      "inputs": [
   312        {
   313          "name": "_name",
   314          "type": "bytes32"
   315        }
   316      ],
   317      "name": "reserve",
   318      "outputs": [],
   319      "type": "function"
   320    },
   321    {
   322      "constant": false,
   323      "inputs": [
   324        {
   325          "name": "_name",
   326          "type": "bytes32"
   327        },
   328        {
   329          "name": "_newOwner",
   330          "type": "address"
   331        }
   332      ],
   333      "name": "transfer",
   334      "outputs": [],
   335      "type": "function"
   336    },
   337    {
   338      "constant": false,
   339      "inputs": [
   340        {
   341          "name": "_name",
   342          "type": "bytes32"
   343        },
   344        {
   345          "name": "_a",
   346          "type": "address"
   347        }
   348      ],
   349      "name": "setAddr",
   350      "outputs": [],
   351      "type": "function"
   352    },
   353    {
   354      "anonymous": false,
   355      "inputs": [
   356        {
   357          "indexed": true,
   358          "name": "name",
   359          "type": "bytes32"
   360        }
   361      ],
   362      "name": "Changed",
   363      "type": "event"
   364    }
   365  ]
   366  
   367  },{}],3:[function(require,module,exports){
   368  module.exports=[
   369    {
   370      "constant": false,
   371      "inputs": [
   372        {
   373          "name": "from",
   374          "type": "bytes32"
   375        },
   376        {
   377          "name": "to",
   378          "type": "address"
   379        },
   380        {
   381          "name": "value",
   382          "type": "uint256"
   383        }
   384      ],
   385      "name": "transfer",
   386      "outputs": [],
   387      "type": "function"
   388    },
   389    {
   390      "constant": false,
   391      "inputs": [
   392        {
   393          "name": "from",
   394          "type": "bytes32"
   395        },
   396        {
   397          "name": "to",
   398          "type": "address"
   399        },
   400        {
   401          "name": "indirectId",
   402          "type": "bytes32"
   403        },
   404        {
   405          "name": "value",
   406          "type": "uint256"
   407        }
   408      ],
   409      "name": "icapTransfer",
   410      "outputs": [],
   411      "type": "function"
   412    },
   413    {
   414      "constant": false,
   415      "inputs": [
   416        {
   417          "name": "to",
   418          "type": "bytes32"
   419        }
   420      ],
   421      "name": "deposit",
   422      "outputs": [],
   423      "payable": true,
   424      "type": "function"
   425    },
   426    {
   427      "anonymous": false,
   428      "inputs": [
   429        {
   430          "indexed": true,
   431          "name": "from",
   432          "type": "address"
   433        },
   434        {
   435          "indexed": false,
   436          "name": "value",
   437          "type": "uint256"
   438        }
   439      ],
   440      "name": "AnonymousDeposit",
   441      "type": "event"
   442    },
   443    {
   444      "anonymous": false,
   445      "inputs": [
   446        {
   447          "indexed": true,
   448          "name": "from",
   449          "type": "address"
   450        },
   451        {
   452          "indexed": true,
   453          "name": "to",
   454          "type": "bytes32"
   455        },
   456        {
   457          "indexed": false,
   458          "name": "value",
   459          "type": "uint256"
   460        }
   461      ],
   462      "name": "Deposit",
   463      "type": "event"
   464    },
   465    {
   466      "anonymous": false,
   467      "inputs": [
   468        {
   469          "indexed": true,
   470          "name": "from",
   471          "type": "bytes32"
   472        },
   473        {
   474          "indexed": true,
   475          "name": "to",
   476          "type": "address"
   477        },
   478        {
   479          "indexed": false,
   480          "name": "value",
   481          "type": "uint256"
   482        }
   483      ],
   484      "name": "Transfer",
   485      "type": "event"
   486    },
   487    {
   488      "anonymous": false,
   489      "inputs": [
   490        {
   491          "indexed": true,
   492          "name": "from",
   493          "type": "bytes32"
   494        },
   495        {
   496          "indexed": true,
   497          "name": "to",
   498          "type": "address"
   499        },
   500        {
   501          "indexed": false,
   502          "name": "indirectId",
   503          "type": "bytes32"
   504        },
   505        {
   506          "indexed": false,
   507          "name": "value",
   508          "type": "uint256"
   509        }
   510      ],
   511      "name": "IcapTransfer",
   512      "type": "event"
   513    }
   514  ]
   515  
   516  },{}],4:[function(require,module,exports){
   517  var f = require('./formatters');
   518  var SolidityType = require('./type');
   519  
   520  /**
   521   * SolidityTypeAddress is a prootype that represents address type
   522   * It matches:
   523   * address
   524   * address[]
   525   * address[4]
   526   * address[][]
   527   * address[3][]
   528   * address[][6][], ...
   529   */
   530  var SolidityTypeAddress = function () {
   531      this._inputFormatter = f.formatInputInt;
   532      this._outputFormatter = f.formatOutputAddress;
   533  };
   534  
   535  SolidityTypeAddress.prototype = new SolidityType({});
   536  SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
   537  
   538  SolidityTypeAddress.prototype.isType = function (name) {
   539      return !!name.match(/address(\[([0-9]*)\])?/);
   540  };
   541  
   542  module.exports = SolidityTypeAddress;
   543  
   544  },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
   545  var f = require('./formatters');
   546  var SolidityType = require('./type');
   547  
   548  /**
   549   * SolidityTypeBool is a prootype that represents bool type
   550   * It matches:
   551   * bool
   552   * bool[]
   553   * bool[4]
   554   * bool[][]
   555   * bool[3][]
   556   * bool[][6][], ...
   557   */
   558  var SolidityTypeBool = function () {
   559      this._inputFormatter = f.formatInputBool;
   560      this._outputFormatter = f.formatOutputBool;
   561  };
   562  
   563  SolidityTypeBool.prototype = new SolidityType({});
   564  SolidityTypeBool.prototype.constructor = SolidityTypeBool;
   565  
   566  SolidityTypeBool.prototype.isType = function (name) {
   567      return !!name.match(/^bool(\[([0-9]*)\])*$/);
   568  };
   569  
   570  module.exports = SolidityTypeBool;
   571  
   572  },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
   573  var f = require('./formatters');
   574  var SolidityType = require('./type');
   575  
   576  /**
   577   * SolidityTypeBytes is a prototype that represents the bytes type.
   578   * It matches:
   579   * bytes
   580   * bytes[]
   581   * bytes[4]
   582   * bytes[][]
   583   * bytes[3][]
   584   * bytes[][6][], ...
   585   * bytes32
   586   * bytes8[4]
   587   * bytes[3][]
   588   */
   589  var SolidityTypeBytes = function () {
   590      this._inputFormatter = f.formatInputBytes;
   591      this._outputFormatter = f.formatOutputBytes;
   592  };
   593  
   594  SolidityTypeBytes.prototype = new SolidityType({});
   595  SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
   596  
   597  SolidityTypeBytes.prototype.isType = function (name) {
   598      return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
   599  };
   600  
   601  module.exports = SolidityTypeBytes;
   602  
   603  },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
   604  /*
   605      This file is part of web3.js.
   606  
   607      web3.js is free software: you can redistribute it and/or modify
   608      it under the terms of the GNU Lesser General Public License as published by
   609      the Free Software Foundation, either version 3 of the License, or
   610      (at your option) any later version.
   611  
   612      web3.js is distributed in the hope that it will be useful,
   613      but WITHOUT ANY WARRANTY; without even the implied warranty of
   614      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   615      GNU Lesser General Public License for more details.
   616  
   617      You should have received a copy of the GNU Lesser General Public License
   618      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   619  */
   620  /**
   621   * @file coder.js
   622   * @author Marek Kotewicz <marek@ethdev.com>
   623   * @date 2015
   624   */
   625  
   626  var f = require('./formatters');
   627  
   628  var SolidityTypeAddress = require('./address');
   629  var SolidityTypeBool = require('./bool');
   630  var SolidityTypeInt = require('./int');
   631  var SolidityTypeUInt = require('./uint');
   632  var SolidityTypeDynamicBytes = require('./dynamicbytes');
   633  var SolidityTypeString = require('./string');
   634  var SolidityTypeReal = require('./real');
   635  var SolidityTypeUReal = require('./ureal');
   636  var SolidityTypeBytes = require('./bytes');
   637  
   638  var isDynamic = function (solidityType, type) {
   639     return solidityType.isDynamicType(type) ||
   640            solidityType.isDynamicArray(type);
   641  };
   642  
   643  /**
   644   * SolidityCoder prototype should be used to encode/decode solidity params of any type
   645   */
   646  var SolidityCoder = function (types) {
   647      this._types = types;
   648  };
   649  
   650  /**
   651   * This method should be used to transform type to SolidityType
   652   *
   653   * @method _requireType
   654   * @param {String} type
   655   * @returns {SolidityType}
   656   * @throws {Error} throws if no matching type is found
   657   */
   658  SolidityCoder.prototype._requireType = function (type) {
   659      var solidityType = this._types.filter(function (t) {
   660          return t.isType(type);
   661      })[0];
   662  
   663      if (!solidityType) {
   664          throw Error('invalid solidity type!: ' + type);
   665      }
   666  
   667      return solidityType;
   668  };
   669  
   670  /**
   671   * Should be used to encode plain param
   672   *
   673   * @method encodeParam
   674   * @param {String} type
   675   * @param {Object} plain param
   676   * @return {String} encoded plain param
   677   */
   678  SolidityCoder.prototype.encodeParam = function (type, param) {
   679      return this.encodeParams([type], [param]);
   680  };
   681  
   682  /**
   683   * Should be used to encode list of params
   684   *
   685   * @method encodeParams
   686   * @param {Array} types
   687   * @param {Array} params
   688   * @return {String} encoded list of params
   689   */
   690  SolidityCoder.prototype.encodeParams = function (types, params) {
   691      var solidityTypes = this.getSolidityTypes(types);
   692  
   693      var encodeds = solidityTypes.map(function (solidityType, index) {
   694          return solidityType.encode(params[index], types[index]);
   695      });
   696  
   697      var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
   698          var staticPartLength = solidityType.staticPartLength(types[index]);
   699          var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
   700  
   701          return acc + (isDynamic(solidityTypes[index], types[index]) ?
   702              32 :
   703              roundedStaticPartLength);
   704      }, 0);
   705  
   706      var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
   707  
   708      return result;
   709  };
   710  
   711  SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
   712      var result = "";
   713      var self = this;
   714  
   715      types.forEach(function (type, i) {
   716          if (isDynamic(solidityTypes[i], types[i])) {
   717              result += f.formatInputInt(dynamicOffset).encode();
   718              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   719              dynamicOffset += e.length / 2;
   720          } else {
   721              // don't add length to dynamicOffset. it's already counted
   722              result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   723          }
   724  
   725          // TODO: figure out nested arrays
   726      });
   727  
   728      types.forEach(function (type, i) {
   729          if (isDynamic(solidityTypes[i], types[i])) {
   730              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   731              dynamicOffset += e.length / 2;
   732              result += e;
   733          }
   734      });
   735      return result;
   736  };
   737  
   738  // TODO: refactor whole encoding!
   739  SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
   740      var self = this;
   741      if (solidityType.isDynamicArray(type)) {
   742          return (function () {
   743              // offset was already set
   744              var nestedName = solidityType.nestedName(type);
   745              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   746              var result = encoded[0];
   747  
   748              (function () {
   749                  var previousLength = 2; // in int
   750                  if (solidityType.isDynamicArray(nestedName)) {
   751                      for (var i = 1; i < encoded.length; i++) {
   752                          previousLength += +(encoded[i - 1])[0] || 0;
   753                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   754                      }
   755                  }
   756              })();
   757  
   758              // first element is length, skip it
   759              (function () {
   760                  for (var i = 0; i < encoded.length - 1; i++) {
   761                      var additionalOffset = result / 2;
   762                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset +  additionalOffset);
   763                  }
   764              })();
   765  
   766              return result;
   767          })();
   768  
   769      } else if (solidityType.isStaticArray(type)) {
   770          return (function () {
   771              var nestedName = solidityType.nestedName(type);
   772              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   773              var result = "";
   774  
   775  
   776              if (solidityType.isDynamicArray(nestedName)) {
   777                  (function () {
   778                      var previousLength = 0; // in int
   779                      for (var i = 0; i < encoded.length; i++) {
   780                          // calculate length of previous item
   781                          previousLength += +(encoded[i - 1] || [])[0] || 0;
   782                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   783                      }
   784                  })();
   785              }
   786  
   787              (function () {
   788                  for (var i = 0; i < encoded.length; i++) {
   789                      var additionalOffset = result / 2;
   790                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
   791                  }
   792              })();
   793  
   794              return result;
   795          })();
   796      }
   797  
   798      return encoded;
   799  };
   800  
   801  /**
   802   * Should be used to decode bytes to plain param
   803   *
   804   * @method decodeParam
   805   * @param {String} type
   806   * @param {String} bytes
   807   * @return {Object} plain param
   808   */
   809  SolidityCoder.prototype.decodeParam = function (type, bytes) {
   810      return this.decodeParams([type], bytes)[0];
   811  };
   812  
   813  /**
   814   * Should be used to decode list of params
   815   *
   816   * @method decodeParam
   817   * @param {Array} types
   818   * @param {String} bytes
   819   * @return {Array} array of plain params
   820   */
   821  SolidityCoder.prototype.decodeParams = function (types, bytes) {
   822      var solidityTypes = this.getSolidityTypes(types);
   823      var offsets = this.getOffsets(types, solidityTypes);
   824  
   825      return solidityTypes.map(function (solidityType, index) {
   826          return solidityType.decode(bytes, offsets[index],  types[index], index);
   827      });
   828  };
   829  
   830  SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
   831      var lengths =  solidityTypes.map(function (solidityType, index) {
   832          return solidityType.staticPartLength(types[index]);
   833      });
   834  
   835      for (var i = 1; i < lengths.length; i++) {
   836           // sum with length of previous element
   837          lengths[i] += lengths[i - 1];
   838      }
   839  
   840      return lengths.map(function (length, index) {
   841          // remove the current length, so the length is sum of previous elements
   842          var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
   843          return length - staticPartLength;
   844      });
   845  };
   846  
   847  SolidityCoder.prototype.getSolidityTypes = function (types) {
   848      var self = this;
   849      return types.map(function (type) {
   850          return self._requireType(type);
   851      });
   852  };
   853  
   854  var coder = new SolidityCoder([
   855      new SolidityTypeAddress(),
   856      new SolidityTypeBool(),
   857      new SolidityTypeInt(),
   858      new SolidityTypeUInt(),
   859      new SolidityTypeDynamicBytes(),
   860      new SolidityTypeBytes(),
   861      new SolidityTypeString(),
   862      new SolidityTypeReal(),
   863      new SolidityTypeUReal()
   864  ]);
   865  
   866  module.exports = coder;
   867  
   868  },{"./address":4,"./bool":5,"./bytes":6,"./dynamicbytes":8,"./formatters":9,"./int":10,"./real":12,"./string":13,"./uint":15,"./ureal":16}],8:[function(require,module,exports){
   869  var f = require('./formatters');
   870  var SolidityType = require('./type');
   871  
   872  var SolidityTypeDynamicBytes = function () {
   873      this._inputFormatter = f.formatInputDynamicBytes;
   874      this._outputFormatter = f.formatOutputDynamicBytes;
   875  };
   876  
   877  SolidityTypeDynamicBytes.prototype = new SolidityType({});
   878  SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
   879  
   880  SolidityTypeDynamicBytes.prototype.isType = function (name) {
   881      return !!name.match(/^bytes(\[([0-9]*)\])*$/);
   882  };
   883  
   884  SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
   885      return true;
   886  };
   887  
   888  module.exports = SolidityTypeDynamicBytes;
   889  
   890  },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
   891  /*
   892      This file is part of web3.js.
   893  
   894      web3.js is free software: you can redistribute it and/or modify
   895      it under the terms of the GNU Lesser General Public License as published by
   896      the Free Software Foundation, either version 3 of the License, or
   897      (at your option) any later version.
   898  
   899      web3.js is distributed in the hope that it will be useful,
   900      but WITHOUT ANY WARRANTY; without even the implied warranty of
   901      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   902      GNU Lesser General Public License for more details.
   903  
   904      You should have received a copy of the GNU Lesser General Public License
   905      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   906  */
   907  /**
   908   * @file formatters.js
   909   * @author Marek Kotewicz <marek@ethdev.com>
   910   * @date 2015
   911   */
   912  
   913  var BigNumber = require('bignumber.js');
   914  var utils = require('../utils/utils');
   915  var c = require('../utils/config');
   916  var SolidityParam = require('./param');
   917  
   918  
   919  /**
   920   * Formats input value to byte representation of int
   921   * If value is negative, return it's two's complement
   922   * If the value is floating point, round it down
   923   *
   924   * @method formatInputInt
   925   * @param {String|Number|BigNumber} value that needs to be formatted
   926   * @returns {SolidityParam}
   927   */
   928  var formatInputInt = function (value) {
   929      BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
   930      var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
   931      return new SolidityParam(result);
   932  };
   933  
   934  /**
   935   * Formats input bytes
   936   *
   937   * @method formatInputBytes
   938   * @param {String}
   939   * @returns {SolidityParam}
   940   */
   941  var formatInputBytes = function (value) {
   942      var result = utils.toHex(value).substr(2);
   943      var l = Math.floor((result.length + 63) / 64);
   944      result = utils.padRight(result, l * 64);
   945      return new SolidityParam(result);
   946  };
   947  
   948  /**
   949   * Formats input bytes
   950   *
   951   * @method formatDynamicInputBytes
   952   * @param {String}
   953   * @returns {SolidityParam}
   954   */
   955  var formatInputDynamicBytes = function (value) {
   956      var result = utils.toHex(value).substr(2);
   957      var length = result.length / 2;
   958      var l = Math.floor((result.length + 63) / 64);
   959      result = utils.padRight(result, l * 64);
   960      return new SolidityParam(formatInputInt(length).value + result);
   961  };
   962  
   963  /**
   964   * Formats input value to byte representation of string
   965   *
   966   * @method formatInputString
   967   * @param {String}
   968   * @returns {SolidityParam}
   969   */
   970  var formatInputString = function (value) {
   971      var result = utils.fromUtf8(value).substr(2);
   972      var length = result.length / 2;
   973      var l = Math.floor((result.length + 63) / 64);
   974      result = utils.padRight(result, l * 64);
   975      return new SolidityParam(formatInputInt(length).value + result);
   976  };
   977  
   978  /**
   979   * Formats input value to byte representation of bool
   980   *
   981   * @method formatInputBool
   982   * @param {Boolean}
   983   * @returns {SolidityParam}
   984   */
   985  var formatInputBool = function (value) {
   986      var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ?  '1' : '0');
   987      return new SolidityParam(result);
   988  };
   989  
   990  /**
   991   * Formats input value to byte representation of real
   992   * Values are multiplied by 2^m and encoded as integers
   993   *
   994   * @method formatInputReal
   995   * @param {String|Number|BigNumber}
   996   * @returns {SolidityParam}
   997   */
   998  var formatInputReal = function (value) {
   999      return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
  1000  };
  1001  
  1002  /**
  1003   * Check if input value is negative
  1004   *
  1005   * @method signedIsNegative
  1006   * @param {String} value is hex format
  1007   * @returns {Boolean} true if it is negative, otherwise false
  1008   */
  1009  var signedIsNegative = function (value) {
  1010      return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
  1011  };
  1012  
  1013  /**
  1014   * Formats right-aligned output bytes to int
  1015   *
  1016   * @method formatOutputInt
  1017   * @param {SolidityParam} param
  1018   * @returns {BigNumber} right-aligned output bytes formatted to big number
  1019   */
  1020  var formatOutputInt = function (param) {
  1021      var value = param.staticPart() || "0";
  1022  
  1023      // check if it's negative number
  1024      // it it is, return two's complement
  1025      if (signedIsNegative(value)) {
  1026          return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
  1027      }
  1028      return new BigNumber(value, 16);
  1029  };
  1030  
  1031  /**
  1032   * Formats right-aligned output bytes to uint
  1033   *
  1034   * @method formatOutputUInt
  1035   * @param {SolidityParam}
  1036   * @returns {BigNumeber} right-aligned output bytes formatted to uint
  1037   */
  1038  var formatOutputUInt = function (param) {
  1039      var value = param.staticPart() || "0";
  1040      return new BigNumber(value, 16);
  1041  };
  1042  
  1043  /**
  1044   * Formats right-aligned output bytes to real
  1045   *
  1046   * @method formatOutputReal
  1047   * @param {SolidityParam}
  1048   * @returns {BigNumber} input bytes formatted to real
  1049   */
  1050  var formatOutputReal = function (param) {
  1051      return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
  1052  };
  1053  
  1054  /**
  1055   * Formats right-aligned output bytes to ureal
  1056   *
  1057   * @method formatOutputUReal
  1058   * @param {SolidityParam}
  1059   * @returns {BigNumber} input bytes formatted to ureal
  1060   */
  1061  var formatOutputUReal = function (param) {
  1062      return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
  1063  };
  1064  
  1065  /**
  1066   * Should be used to format output bool
  1067   *
  1068   * @method formatOutputBool
  1069   * @param {SolidityParam}
  1070   * @returns {Boolean} right-aligned input bytes formatted to bool
  1071   */
  1072  var formatOutputBool = function (param) {
  1073      return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
  1074  };
  1075  
  1076  /**
  1077   * Should be used to format output bytes
  1078   *
  1079   * @method formatOutputBytes
  1080   * @param {SolidityParam} left-aligned hex representation of string
  1081   * @param {String} name type name
  1082   * @returns {String} hex string
  1083   */
  1084  var formatOutputBytes = function (param, name) {
  1085      var matches = name.match(/^bytes([0-9]*)/);
  1086      var size = parseInt(matches[1]);
  1087      return '0x' + param.staticPart().slice(0, 2 * size);
  1088  };
  1089  
  1090  /**
  1091   * Should be used to format output bytes
  1092   *
  1093   * @method formatOutputDynamicBytes
  1094   * @param {SolidityParam} left-aligned hex representation of string
  1095   * @returns {String} hex string
  1096   */
  1097  var formatOutputDynamicBytes = function (param) {
  1098      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1099      return '0x' + param.dynamicPart().substr(64, length);
  1100  };
  1101  
  1102  /**
  1103   * Should be used to format output string
  1104   *
  1105   * @method formatOutputString
  1106   * @param {SolidityParam} left-aligned hex representation of string
  1107   * @returns {String} ascii string
  1108   */
  1109  var formatOutputString = function (param) {
  1110      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1111      return utils.toUtf8(param.dynamicPart().substr(64, length));
  1112  };
  1113  
  1114  /**
  1115   * Should be used to format output address
  1116   *
  1117   * @method formatOutputAddress
  1118   * @param {SolidityParam} right-aligned input bytes
  1119   * @returns {String} address
  1120   */
  1121  var formatOutputAddress = function (param) {
  1122      var value = param.staticPart();
  1123      return "0x" + value.slice(value.length - 40, value.length);
  1124  };
  1125  
  1126  module.exports = {
  1127      formatInputInt: formatInputInt,
  1128      formatInputBytes: formatInputBytes,
  1129      formatInputDynamicBytes: formatInputDynamicBytes,
  1130      formatInputString: formatInputString,
  1131      formatInputBool: formatInputBool,
  1132      formatInputReal: formatInputReal,
  1133      formatOutputInt: formatOutputInt,
  1134      formatOutputUInt: formatOutputUInt,
  1135      formatOutputReal: formatOutputReal,
  1136      formatOutputUReal: formatOutputUReal,
  1137      formatOutputBool: formatOutputBool,
  1138      formatOutputBytes: formatOutputBytes,
  1139      formatOutputDynamicBytes: formatOutputDynamicBytes,
  1140      formatOutputString: formatOutputString,
  1141      formatOutputAddress: formatOutputAddress
  1142  };
  1143  
  1144  },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
  1145  var f = require('./formatters');
  1146  var SolidityType = require('./type');
  1147  
  1148  /**
  1149   * SolidityTypeInt is a prootype that represents int type
  1150   * It matches:
  1151   * int
  1152   * int[]
  1153   * int[4]
  1154   * int[][]
  1155   * int[3][]
  1156   * int[][6][], ...
  1157   * int32
  1158   * int64[]
  1159   * int8[4]
  1160   * int256[][]
  1161   * int[3][]
  1162   * int64[][6][], ...
  1163   */
  1164  var SolidityTypeInt = function () {
  1165      this._inputFormatter = f.formatInputInt;
  1166      this._outputFormatter = f.formatOutputInt;
  1167  };
  1168  
  1169  SolidityTypeInt.prototype = new SolidityType({});
  1170  SolidityTypeInt.prototype.constructor = SolidityTypeInt;
  1171  
  1172  SolidityTypeInt.prototype.isType = function (name) {
  1173      return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
  1174  };
  1175  
  1176  module.exports = SolidityTypeInt;
  1177  
  1178  },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
  1179  /*
  1180      This file is part of web3.js.
  1181  
  1182      web3.js is free software: you can redistribute it and/or modify
  1183      it under the terms of the GNU Lesser General Public License as published by
  1184      the Free Software Foundation, either version 3 of the License, or
  1185      (at your option) any later version.
  1186  
  1187      web3.js is distributed in the hope that it will be useful,
  1188      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1189      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1190      GNU Lesser General Public License for more details.
  1191  
  1192      You should have received a copy of the GNU Lesser General Public License
  1193      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1194  */
  1195  /** 
  1196   * @file param.js
  1197   * @author Marek Kotewicz <marek@ethdev.com>
  1198   * @date 2015
  1199   */
  1200  
  1201  var utils = require('../utils/utils');
  1202  
  1203  /**
  1204   * SolidityParam object prototype.
  1205   * Should be used when encoding, decoding solidity bytes
  1206   */
  1207  var SolidityParam = function (value, offset) {
  1208      this.value = value || '';
  1209      this.offset = offset; // offset in bytes
  1210  };
  1211  
  1212  /**
  1213   * This method should be used to get length of params's dynamic part
  1214   * 
  1215   * @method dynamicPartLength
  1216   * @returns {Number} length of dynamic part (in bytes)
  1217   */
  1218  SolidityParam.prototype.dynamicPartLength = function () {
  1219      return this.dynamicPart().length / 2;
  1220  };
  1221  
  1222  /**
  1223   * This method should be used to create copy of solidity param with different offset
  1224   *
  1225   * @method withOffset
  1226   * @param {Number} offset length in bytes
  1227   * @returns {SolidityParam} new solidity param with applied offset
  1228   */
  1229  SolidityParam.prototype.withOffset = function (offset) {
  1230      return new SolidityParam(this.value, offset);
  1231  };
  1232  
  1233  /**
  1234   * This method should be used to combine solidity params together
  1235   * eg. when appending an array
  1236   *
  1237   * @method combine
  1238   * @param {SolidityParam} param with which we should combine
  1239   * @param {SolidityParam} result of combination
  1240   */
  1241  SolidityParam.prototype.combine = function (param) {
  1242      return new SolidityParam(this.value + param.value); 
  1243  };
  1244  
  1245  /**
  1246   * This method should be called to check if param has dynamic size.
  1247   * If it has, it returns true, otherwise false
  1248   *
  1249   * @method isDynamic
  1250   * @returns {Boolean}
  1251   */
  1252  SolidityParam.prototype.isDynamic = function () {
  1253      return this.offset !== undefined;
  1254  };
  1255  
  1256  /**
  1257   * This method should be called to transform offset to bytes
  1258   *
  1259   * @method offsetAsBytes
  1260   * @returns {String} bytes representation of offset
  1261   */
  1262  SolidityParam.prototype.offsetAsBytes = function () {
  1263      return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
  1264  };
  1265  
  1266  /**
  1267   * This method should be called to get static part of param
  1268   *
  1269   * @method staticPart
  1270   * @returns {String} offset if it is a dynamic param, otherwise value
  1271   */
  1272  SolidityParam.prototype.staticPart = function () {
  1273      if (!this.isDynamic()) {
  1274          return this.value; 
  1275      } 
  1276      return this.offsetAsBytes();
  1277  };
  1278  
  1279  /**
  1280   * This method should be called to get dynamic part of param
  1281   *
  1282   * @method dynamicPart
  1283   * @returns {String} returns a value if it is a dynamic param, otherwise empty string
  1284   */
  1285  SolidityParam.prototype.dynamicPart = function () {
  1286      return this.isDynamic() ? this.value : '';
  1287  };
  1288  
  1289  /**
  1290   * This method should be called to encode param
  1291   *
  1292   * @method encode
  1293   * @returns {String}
  1294   */
  1295  SolidityParam.prototype.encode = function () {
  1296      return this.staticPart() + this.dynamicPart();
  1297  };
  1298  
  1299  /**
  1300   * This method should be called to encode array of params
  1301   *
  1302   * @method encodeList
  1303   * @param {Array[SolidityParam]} params
  1304   * @returns {String}
  1305   */
  1306  SolidityParam.encodeList = function (params) {
  1307      
  1308      // updating offsets
  1309      var totalOffset = params.length * 32;
  1310      var offsetParams = params.map(function (param) {
  1311          if (!param.isDynamic()) {
  1312              return param;
  1313          }
  1314          var offset = totalOffset;
  1315          totalOffset += param.dynamicPartLength();
  1316          return param.withOffset(offset);
  1317      });
  1318  
  1319      // encode everything!
  1320      return offsetParams.reduce(function (result, param) {
  1321          return result + param.dynamicPart();
  1322      }, offsetParams.reduce(function (result, param) {
  1323          return result + param.staticPart();
  1324      }, ''));
  1325  };
  1326  
  1327  
  1328  
  1329  module.exports = SolidityParam;
  1330  
  1331  
  1332  },{"../utils/utils":20}],12:[function(require,module,exports){
  1333  var f = require('./formatters');
  1334  var SolidityType = require('./type');
  1335  
  1336  /**
  1337   * SolidityTypeReal is a prootype that represents real type
  1338   * It matches:
  1339   * real
  1340   * real[]
  1341   * real[4]
  1342   * real[][]
  1343   * real[3][]
  1344   * real[][6][], ...
  1345   * real32
  1346   * real64[]
  1347   * real8[4]
  1348   * real256[][]
  1349   * real[3][]
  1350   * real64[][6][], ...
  1351   */
  1352  var SolidityTypeReal = function () {
  1353      this._inputFormatter = f.formatInputReal;
  1354      this._outputFormatter = f.formatOutputReal;
  1355  };
  1356  
  1357  SolidityTypeReal.prototype = new SolidityType({});
  1358  SolidityTypeReal.prototype.constructor = SolidityTypeReal;
  1359  
  1360  SolidityTypeReal.prototype.isType = function (name) {
  1361      return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
  1362  };
  1363  
  1364  module.exports = SolidityTypeReal;
  1365  
  1366  },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
  1367  var f = require('./formatters');
  1368  var SolidityType = require('./type');
  1369  
  1370  var SolidityTypeString = function () {
  1371      this._inputFormatter = f.formatInputString;
  1372      this._outputFormatter = f.formatOutputString;
  1373  };
  1374  
  1375  SolidityTypeString.prototype = new SolidityType({});
  1376  SolidityTypeString.prototype.constructor = SolidityTypeString;
  1377  
  1378  SolidityTypeString.prototype.isType = function (name) {
  1379      return !!name.match(/^string(\[([0-9]*)\])*$/);
  1380  };
  1381  
  1382  SolidityTypeString.prototype.isDynamicType = function () {
  1383      return true;
  1384  };
  1385  
  1386  module.exports = SolidityTypeString;
  1387  
  1388  },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
  1389  var f = require('./formatters');
  1390  var SolidityParam = require('./param');
  1391  
  1392  /**
  1393   * SolidityType prototype is used to encode/decode solidity params of certain type
  1394   */
  1395  var SolidityType = function (config) {
  1396      this._inputFormatter = config.inputFormatter;
  1397      this._outputFormatter = config.outputFormatter;
  1398  };
  1399  
  1400  /**
  1401   * Should be used to determine if this SolidityType do match given name
  1402   *
  1403   * @method isType
  1404   * @param {String} name
  1405   * @return {Bool} true if type match this SolidityType, otherwise false
  1406   */
  1407  SolidityType.prototype.isType = function (name) {
  1408      throw "this method should be overrwritten for type " + name;
  1409  };
  1410  
  1411  /**
  1412   * Should be used to determine what is the length of static part in given type
  1413   *
  1414   * @method staticPartLength
  1415   * @param {String} name
  1416   * @return {Number} length of static part in bytes
  1417   */
  1418  SolidityType.prototype.staticPartLength = function (name) {
  1419      // If name isn't an array then treat it like a single element array.
  1420      return (this.nestedTypes(name) || ['[1]'])
  1421          .map(function (type) {
  1422              // the length of the nested array
  1423              return parseInt(type.slice(1, -1), 10) || 1;
  1424          })
  1425          .reduce(function (previous, current) {
  1426              return previous * current;
  1427          // all basic types are 32 bytes long
  1428          }, 32);
  1429  };
  1430  
  1431  /**
  1432   * Should be used to determine if type is dynamic array
  1433   * eg:
  1434   * "type[]" => true
  1435   * "type[4]" => false
  1436   *
  1437   * @method isDynamicArray
  1438   * @param {String} name
  1439   * @return {Bool} true if the type is dynamic array
  1440   */
  1441  SolidityType.prototype.isDynamicArray = function (name) {
  1442      var nestedTypes = this.nestedTypes(name);
  1443      return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1444  };
  1445  
  1446  /**
  1447   * Should be used to determine if type is static array
  1448   * eg:
  1449   * "type[]" => false
  1450   * "type[4]" => true
  1451   *
  1452   * @method isStaticArray
  1453   * @param {String} name
  1454   * @return {Bool} true if the type is static array
  1455   */
  1456  SolidityType.prototype.isStaticArray = function (name) {
  1457      var nestedTypes = this.nestedTypes(name);
  1458      return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1459  };
  1460  
  1461  /**
  1462   * Should return length of static array
  1463   * eg.
  1464   * "int[32]" => 32
  1465   * "int256[14]" => 14
  1466   * "int[2][3]" => 3
  1467   * "int" => 1
  1468   * "int[1]" => 1
  1469   * "int[]" => 1
  1470   *
  1471   * @method staticArrayLength
  1472   * @param {String} name
  1473   * @return {Number} static array length
  1474   */
  1475  SolidityType.prototype.staticArrayLength = function (name) {
  1476      var nestedTypes = this.nestedTypes(name);
  1477      if (nestedTypes) {
  1478         return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
  1479      }
  1480      return 1;
  1481  };
  1482  
  1483  /**
  1484   * Should return nested type
  1485   * eg.
  1486   * "int[32]" => "int"
  1487   * "int256[14]" => "int256"
  1488   * "int[2][3]" => "int[2]"
  1489   * "int" => "int"
  1490   * "int[]" => "int"
  1491   *
  1492   * @method nestedName
  1493   * @param {String} name
  1494   * @return {String} nested name
  1495   */
  1496  SolidityType.prototype.nestedName = function (name) {
  1497      // remove last [] in name
  1498      var nestedTypes = this.nestedTypes(name);
  1499      if (!nestedTypes) {
  1500          return name;
  1501      }
  1502  
  1503      return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
  1504  };
  1505  
  1506  /**
  1507   * Should return true if type has dynamic size by default
  1508   * such types are "string", "bytes"
  1509   *
  1510   * @method isDynamicType
  1511   * @param {String} name
  1512   * @return {Bool} true if is dynamic, otherwise false
  1513   */
  1514  SolidityType.prototype.isDynamicType = function () {
  1515      return false;
  1516  };
  1517  
  1518  /**
  1519   * Should return array of nested types
  1520   * eg.
  1521   * "int[2][3][]" => ["[2]", "[3]", "[]"]
  1522   * "int[] => ["[]"]
  1523   * "int" => null
  1524   *
  1525   * @method nestedTypes
  1526   * @param {String} name
  1527   * @return {Array} array of nested types
  1528   */
  1529  SolidityType.prototype.nestedTypes = function (name) {
  1530      // return list of strings eg. "[]", "[3]", "[]", "[2]"
  1531      return name.match(/(\[[0-9]*\])/g);
  1532  };
  1533  
  1534  /**
  1535   * Should be used to encode the value
  1536   *
  1537   * @method encode
  1538   * @param {Object} value
  1539   * @param {String} name
  1540   * @return {String} encoded value
  1541   */
  1542  SolidityType.prototype.encode = function (value, name) {
  1543      var self = this;
  1544      if (this.isDynamicArray(name)) {
  1545  
  1546          return (function () {
  1547              var length = value.length;                          // in int
  1548              var nestedName = self.nestedName(name);
  1549  
  1550              var result = [];
  1551              result.push(f.formatInputInt(length).encode());
  1552  
  1553              value.forEach(function (v) {
  1554                  result.push(self.encode(v, nestedName));
  1555              });
  1556  
  1557              return result;
  1558          })();
  1559  
  1560      } else if (this.isStaticArray(name)) {
  1561  
  1562          return (function () {
  1563              var length = self.staticArrayLength(name);          // in int
  1564              var nestedName = self.nestedName(name);
  1565  
  1566              var result = [];
  1567              for (var i = 0; i < length; i++) {
  1568                  result.push(self.encode(value[i], nestedName));
  1569              }
  1570  
  1571              return result;
  1572          })();
  1573  
  1574      }
  1575  
  1576      return this._inputFormatter(value, name).encode();
  1577  };
  1578  
  1579  /**
  1580   * Should be used to decode value from bytes
  1581   *
  1582   * @method decode
  1583   * @param {String} bytes
  1584   * @param {Number} offset in bytes
  1585   * @param {String} name type name
  1586   * @returns {Object} decoded value
  1587   */
  1588  SolidityType.prototype.decode = function (bytes, offset, name) {
  1589      var self = this;
  1590  
  1591      if (this.isDynamicArray(name)) {
  1592  
  1593          return (function () {
  1594              var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1595              var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
  1596              var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
  1597  
  1598              var nestedName = self.nestedName(name);
  1599              var nestedStaticPartLength = self.staticPartLength(nestedName);  // in bytes
  1600              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1601              var result = [];
  1602  
  1603              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1604                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1605              }
  1606  
  1607              return result;
  1608          })();
  1609  
  1610      } else if (this.isStaticArray(name)) {
  1611  
  1612          return (function () {
  1613              var length = self.staticArrayLength(name);                      // in int
  1614              var arrayStart = offset;                                        // in bytes
  1615  
  1616              var nestedName = self.nestedName(name);
  1617              var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1618              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1619              var result = [];
  1620  
  1621              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1622                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1623              }
  1624  
  1625              return result;
  1626          })();
  1627      } else if (this.isDynamicType(name)) {
  1628  
  1629          return (function () {
  1630              var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64));      // in bytes
  1631              var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64));      // in bytes
  1632              var roundedLength = Math.floor((length + 31) / 32);                     // in int
  1633              var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
  1634              return self._outputFormatter(param, name);
  1635          })();
  1636      }
  1637  
  1638      var length = this.staticPartLength(name);
  1639      var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
  1640      return this._outputFormatter(param, name);
  1641  };
  1642  
  1643  module.exports = SolidityType;
  1644  
  1645  },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
  1646  var f = require('./formatters');
  1647  var SolidityType = require('./type');
  1648  
  1649  /**
  1650   * SolidityTypeUInt is a prootype that represents uint type
  1651   * It matches:
  1652   * uint
  1653   * uint[]
  1654   * uint[4]
  1655   * uint[][]
  1656   * uint[3][]
  1657   * uint[][6][], ...
  1658   * uint32
  1659   * uint64[]
  1660   * uint8[4]
  1661   * uint256[][]
  1662   * uint[3][]
  1663   * uint64[][6][], ...
  1664   */
  1665  var SolidityTypeUInt = function () {
  1666      this._inputFormatter = f.formatInputInt;
  1667      this._outputFormatter = f.formatOutputUInt;
  1668  };
  1669  
  1670  SolidityTypeUInt.prototype = new SolidityType({});
  1671  SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
  1672  
  1673  SolidityTypeUInt.prototype.isType = function (name) {
  1674      return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
  1675  };
  1676  
  1677  module.exports = SolidityTypeUInt;
  1678  
  1679  },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
  1680  var f = require('./formatters');
  1681  var SolidityType = require('./type');
  1682  
  1683  /**
  1684   * SolidityTypeUReal is a prootype that represents ureal type
  1685   * It matches:
  1686   * ureal
  1687   * ureal[]
  1688   * ureal[4]
  1689   * ureal[][]
  1690   * ureal[3][]
  1691   * ureal[][6][], ...
  1692   * ureal32
  1693   * ureal64[]
  1694   * ureal8[4]
  1695   * ureal256[][]
  1696   * ureal[3][]
  1697   * ureal64[][6][], ...
  1698   */
  1699  var SolidityTypeUReal = function () {
  1700      this._inputFormatter = f.formatInputReal;
  1701      this._outputFormatter = f.formatOutputUReal;
  1702  };
  1703  
  1704  SolidityTypeUReal.prototype = new SolidityType({});
  1705  SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
  1706  
  1707  SolidityTypeUReal.prototype.isType = function (name) {
  1708      return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
  1709  };
  1710  
  1711  module.exports = SolidityTypeUReal;
  1712  
  1713  },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
  1714  'use strict';
  1715  
  1716  // go env doesn't have and need XMLHttpRequest
  1717  if (typeof XMLHttpRequest === 'undefined') {
  1718      exports.XMLHttpRequest = {};
  1719  } else {
  1720      exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
  1721  }
  1722  
  1723  
  1724  },{}],18:[function(require,module,exports){
  1725  /*
  1726      This file is part of web3.js.
  1727  
  1728      web3.js is free software: you can redistribute it and/or modify
  1729      it under the terms of the GNU Lesser General Public License as published by
  1730      the Free Software Foundation, either version 3 of the License, or
  1731      (at your option) any later version.
  1732  
  1733      web3.js is distributed in the hope that it will be useful,
  1734      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1735      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1736      GNU Lesser General Public License for more details.
  1737  
  1738      You should have received a copy of the GNU Lesser General Public License
  1739      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1740  */
  1741  /** @file config.js
  1742   * @authors:
  1743   *   Marek Kotewicz <marek@ethdev.com>
  1744   * @date 2015
  1745   */
  1746  
  1747  /**
  1748   * Utils
  1749   * 
  1750   * @module utils
  1751   */
  1752  
  1753  /**
  1754   * Utility functions
  1755   * 
  1756   * @class [utils] config
  1757   * @constructor
  1758   */
  1759  
  1760  
  1761  /// required to define ETH_BIGNUMBER_ROUNDING_MODE
  1762  var BigNumber = require('bignumber.js');
  1763  
  1764  var ETH_UNITS = [
  1765      'wei',
  1766      'kwei',
  1767      'Mwei',
  1768      'Gwei',
  1769      'szabo',
  1770      'finney',
  1771      'femtoether',
  1772      'picoether',
  1773      'nanoether',
  1774      'microether',
  1775      'milliether',
  1776      'nano',
  1777      'micro',
  1778      'milli',
  1779      'ether',
  1780      'grand',
  1781      'Mether',
  1782      'Gether',
  1783      'Tether',
  1784      'Pether',
  1785      'Eether',
  1786      'Zether',
  1787      'Yether',
  1788      'Nether',
  1789      'Dether',
  1790      'Vether',
  1791      'Uether'
  1792  ];
  1793  
  1794  module.exports = {
  1795      ETH_PADDING: 32,
  1796      ETH_SIGNATURE_LENGTH: 4,
  1797      ETH_UNITS: ETH_UNITS,
  1798      ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
  1799      ETH_POLLING_TIMEOUT: 1000/2,
  1800      defaultBlock: 'latest',
  1801      defaultAccount: undefined
  1802  };
  1803  
  1804  
  1805  },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
  1806  /*
  1807      This file is part of web3.js.
  1808  
  1809      web3.js is free software: you can redistribute it and/or modify
  1810      it under the terms of the GNU Lesser General Public License as published by
  1811      the Free Software Foundation, either version 3 of the License, or
  1812      (at your option) any later version.
  1813  
  1814      web3.js is distributed in the hope that it will be useful,
  1815      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1816      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1817      GNU Lesser General Public License for more details.
  1818  
  1819      You should have received a copy of the GNU Lesser General Public License
  1820      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1821  */
  1822  /** 
  1823   * @file sha3.js
  1824   * @author Marek Kotewicz <marek@ethdev.com>
  1825   * @date 2015
  1826   */
  1827  
  1828  var CryptoJS = require('crypto-js');
  1829  var sha3 = require('crypto-js/sha3');
  1830  
  1831  module.exports = function (value, options) {
  1832      if (options && options.encoding === 'hex') {
  1833          if (value.length > 2 && value.substr(0, 2) === '0x') {
  1834              value = value.substr(2);
  1835          }
  1836          value = CryptoJS.enc.Hex.parse(value);
  1837      }
  1838  
  1839      return sha3(value, {
  1840          outputLength: 256
  1841      }).toString();
  1842  };
  1843  
  1844  
  1845  },{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
  1846  /*
  1847      This file is part of web3.js.
  1848  
  1849      web3.js is free software: you can redistribute it and/or modify
  1850      it under the terms of the GNU Lesser General Public License as published by
  1851      the Free Software Foundation, either version 3 of the License, or
  1852      (at your option) any later version.
  1853  
  1854      web3.js is distributed in the hope that it will be useful,
  1855      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1856      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1857      GNU Lesser General Public License for more details.
  1858  
  1859      You should have received a copy of the GNU Lesser General Public License
  1860      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1861  */
  1862  /**
  1863   * @file utils.js
  1864   * @author Marek Kotewicz <marek@ethdev.com>
  1865   * @date 2015
  1866   */
  1867  
  1868  /**
  1869   * Utils
  1870   *
  1871   * @module utils
  1872   */
  1873  
  1874  /**
  1875   * Utility functions
  1876   *
  1877   * @class [utils] utils
  1878   * @constructor
  1879   */
  1880  
  1881  
  1882  var BigNumber = require('bignumber.js');
  1883  var sha3 = require('./sha3.js');
  1884  var utf8 = require('utf8');
  1885  
  1886  var unitMap = {
  1887      'noether':      '0',
  1888      'wei':          '1',
  1889      'kwei':         '1000',
  1890      'Kwei':         '1000',
  1891      'babbage':      '1000',
  1892      'femtoether':   '1000',
  1893      'mwei':         '1000000',
  1894      'Mwei':         '1000000',
  1895      'lovelace':     '1000000',
  1896      'picoether':    '1000000',
  1897      'gwei':         '1000000000',
  1898      'Gwei':         '1000000000',
  1899      'shannon':      '1000000000',
  1900      'nanoether':    '1000000000',
  1901      'nano':         '1000000000',
  1902      'szabo':        '1000000000000',
  1903      'microether':   '1000000000000',
  1904      'micro':        '1000000000000',
  1905      'finney':       '1000000000000000',
  1906      'milliether':   '1000000000000000',
  1907      'milli':        '1000000000000000',
  1908      'ether':        '1000000000000000000',
  1909      'neat':         '1000000000000000000',
  1910      'kether':       '1000000000000000000000',
  1911      'kneat':        '1000000000000000000000',
  1912      'grand':        '1000000000000000000000',
  1913      'mether':       '1000000000000000000000000',
  1914      'mneat':        '1000000000000000000000000',
  1915      'gether':       '1000000000000000000000000000',
  1916      'gneat':        '1000000000000000000000000000',
  1917      'tneat':        '1000000000000000000000000000000',
  1918      'tether':       '1000000000000000000000000000000'
  1919  };
  1920  
  1921  /**
  1922   * Should be called to pad string to expected length
  1923   *
  1924   * @method padLeft
  1925   * @param {String} string to be padded
  1926   * @param {Number} characters that result string should have
  1927   * @param {String} sign, by default 0
  1928   * @returns {String} right aligned string
  1929   */
  1930  var padLeft = function (string, chars, sign) {
  1931      return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1932  };
  1933  
  1934  /**
  1935   * Should be called to pad string to expected length
  1936   *
  1937   * @method padRight
  1938   * @param {String} string to be padded
  1939   * @param {Number} characters that result string should have
  1940   * @param {String} sign, by default 0
  1941   * @returns {String} right aligned string
  1942   */
  1943  var padRight = function (string, chars, sign) {
  1944      return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1945  };
  1946  
  1947  /**
  1948   * Should be called to get utf8 from it's hex representation
  1949   *
  1950   * @method toUtf8
  1951   * @param {String} string in hex
  1952   * @returns {String} ascii string representation of hex value
  1953   */
  1954  var toUtf8 = function(hex) {
  1955  // Find termination
  1956      var str = "";
  1957      var i = 0, l = hex.length;
  1958      if (hex.substring(0, 2) === '0x') {
  1959          i = 2;
  1960      }
  1961      for (; i < l; i+=2) {
  1962          var code = parseInt(hex.substr(i, 2), 16);
  1963          if (code === 0)
  1964              break;
  1965          str += String.fromCharCode(code);
  1966      }
  1967  
  1968      return utf8.decode(str);
  1969  };
  1970  
  1971  /**
  1972   * Should be called to get ascii from it's hex representation
  1973   *
  1974   * @method toAscii
  1975   * @param {String} string in hex
  1976   * @returns {String} ascii string representation of hex value
  1977   */
  1978  var toAscii = function(hex) {
  1979  // Find termination
  1980      var str = "";
  1981      var i = 0, l = hex.length;
  1982      if (hex.substring(0, 2) === '0x') {
  1983          i = 2;
  1984      }
  1985      for (; i < l; i+=2) {
  1986          var code = parseInt(hex.substr(i, 2), 16);
  1987          str += String.fromCharCode(code);
  1988      }
  1989  
  1990      return str;
  1991  };
  1992  
  1993  /**
  1994   * Should be called to get hex representation (prefixed by 0x) of utf8 string
  1995   *
  1996   * @method fromUtf8
  1997   * @param {String} string
  1998   * @param {Number} optional padding
  1999   * @returns {String} hex representation of input string
  2000   */
  2001  var fromUtf8 = function(str) {
  2002      str = utf8.encode(str);
  2003      var hex = "";
  2004      for(var i = 0; i < str.length; i++) {
  2005          var code = str.charCodeAt(i);
  2006          if (code === 0)
  2007              break;
  2008          var n = code.toString(16);
  2009          hex += n.length < 2 ? '0' + n : n;
  2010      }
  2011  
  2012      return "0x" + hex;
  2013  };
  2014  
  2015  /**
  2016   * Should be called to get hex representation (prefixed by 0x) of ascii string
  2017   *
  2018   * @method fromAscii
  2019   * @param {String} string
  2020   * @param {Number} optional padding
  2021   * @returns {String} hex representation of input string
  2022   */
  2023  var fromAscii = function(str) {
  2024      var hex = "";
  2025      for(var i = 0; i < str.length; i++) {
  2026          var code = str.charCodeAt(i);
  2027          var n = code.toString(16);
  2028          hex += n.length < 2 ? '0' + n : n;
  2029      }
  2030  
  2031      return "0x" + hex;
  2032  };
  2033  
  2034  /**
  2035   * Should be used to create full function/event name from json abi
  2036   *
  2037   * @method transformToFullName
  2038   * @param {Object} json-abi
  2039   * @return {String} full fnction/event name
  2040   */
  2041  var transformToFullName = function (json) {
  2042      if (json.name.indexOf('(') !== -1) {
  2043          return json.name;
  2044      }
  2045  
  2046      var typeName = json.inputs.map(function(i){return i.type; }).join();
  2047      return json.name + '(' + typeName + ')';
  2048  };
  2049  
  2050  /**
  2051   * Should be called to get display name of contract function
  2052   *
  2053   * @method extractDisplayName
  2054   * @param {String} name of function/event
  2055   * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  2056   */
  2057  var extractDisplayName = function (name) {
  2058      var length = name.indexOf('(');
  2059      return length !== -1 ? name.substr(0, length) : name;
  2060  };
  2061  
  2062  /// @returns overloaded part of function/event name
  2063  var extractTypeName = function (name) {
  2064      /// TODO: make it invulnerable
  2065      var length = name.indexOf('(');
  2066      return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  2067  };
  2068  
  2069  /**
  2070   * Converts value to it's decimal representation in string
  2071   *
  2072   * @method toDecimal
  2073   * @param {String|Number|BigNumber}
  2074   * @return {String}
  2075   */
  2076  var toDecimal = function (value) {
  2077      return toBigNumber(value).toNumber();
  2078  };
  2079  
  2080  /**
  2081   * Converts value to it's hex representation
  2082   *
  2083   * @method fromDecimal
  2084   * @param {String|Number|BigNumber}
  2085   * @return {String}
  2086   */
  2087  var fromDecimal = function (value) {
  2088      var number = toBigNumber(value);
  2089      var result = number.toString(16);
  2090  
  2091      return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  2092  };
  2093  
  2094  /**
  2095   * Auto converts any given value into it's hex representation.
  2096   *
  2097   * And even stringifys objects before.
  2098   *
  2099   * @method toHex
  2100   * @param {String|Number|BigNumber|Object}
  2101   * @return {String}
  2102   */
  2103  var toHex = function (val) {
  2104      /*jshint maxcomplexity: 8 */
  2105  
  2106      if (isBoolean(val))
  2107          return fromDecimal(+val);
  2108  
  2109      if (isBigNumber(val))
  2110          return fromDecimal(val);
  2111  
  2112      if (typeof val === 'object')
  2113          return fromUtf8(JSON.stringify(val));
  2114  
  2115      // if its a negative number, pass it through fromDecimal
  2116      if (isString(val)) {
  2117          if (val.indexOf('-0x') === 0)
  2118              return fromDecimal(val);
  2119          else if(val.indexOf('0x') === 0)
  2120              return val;
  2121          else if (!isFinite(val))
  2122              return fromAscii(val);
  2123      }
  2124  
  2125      return fromDecimal(val);
  2126  };
  2127  
  2128  /**
  2129   * Returns value of unit in Wei
  2130   *
  2131   * @method getValueOfUnit
  2132   * @param {String} unit the unit to convert to, default ether
  2133   * @returns {BigNumber} value of the unit (in Wei)
  2134   * @throws error if the unit is not correct:w
  2135   */
  2136  var getValueOfUnit = function (unit) {
  2137      unit = unit ? unit.toLowerCase() : 'ether';
  2138      var unitValue = unitMap[unit];
  2139      if (unitValue === undefined) {
  2140          throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  2141      }
  2142      return new BigNumber(unitValue, 10);
  2143  };
  2144  
  2145  /**
  2146   * Takes a number of wei and converts it to any other ether unit.
  2147   *
  2148   * Possible units are:
  2149   *   SI Short   SI Full        Effigy       Other
  2150   * - kwei       femtoether     babbage
  2151   * - mwei       picoether      lovelace
  2152   * - gwei       nanoether      shannon      nano
  2153   * - --         microether     szabo        micro
  2154   * - --         milliether     finney       milli
  2155   * - ether      --             --
  2156   * - kether                    --           grand
  2157   * - mether
  2158   * - gether
  2159   * - tether
  2160   *
  2161   * @method fromWei
  2162   * @param {Number|String} number can be a number, number string or a HEX of a decimal
  2163   * @param {String} unit the unit to convert to, default ether
  2164   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2165  */
  2166  var fromWei = function(number, unit) {
  2167      var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  2168  
  2169      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2170  };
  2171  
  2172  /**
  2173   * Takes a number of a unit and converts it to wei.
  2174   *
  2175   * Possible units are:
  2176   *   SI Short   SI Full        Effigy       Other
  2177   * - kwei       femtoether     babbage
  2178   * - mwei       picoether      lovelace
  2179   * - gwei       nanoether      shannon      nano
  2180   * - --         microether     szabo        micro
  2181   * - --         microether     szabo        micro
  2182   * - --         milliether     finney       milli
  2183   * - ether      --             --
  2184   * - kether                    --           grand
  2185   * - mether
  2186   * - gether
  2187   * - tether
  2188   *
  2189   * @method toWei
  2190   * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  2191   * @param {String} unit the unit to convert from, default ether
  2192   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2193  */
  2194  var toWei = function(number, unit) {
  2195      var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  2196  
  2197      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2198  };
  2199  
  2200  /**
  2201   * Takes an input and transforms it into an bignumber
  2202   *
  2203   * @method toBigNumber
  2204   * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  2205   * @return {BigNumber} BigNumber
  2206  */
  2207  var toBigNumber = function(number) {
  2208      /*jshint maxcomplexity:5 */
  2209      number = number || 0;
  2210      if (isBigNumber(number))
  2211          return number;
  2212  
  2213      if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  2214          return new BigNumber(number.replace('0x',''), 16);
  2215      }
  2216  
  2217      return new BigNumber(number.toString(10), 10);
  2218  };
  2219  
  2220  /**
  2221   * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  2222   *
  2223   * @method toTwosComplement
  2224   * @param {Number|String|BigNumber}
  2225   * @return {BigNumber}
  2226   */
  2227  var toTwosComplement = function (number) {
  2228      var bigNumber = toBigNumber(number).round();
  2229      if (bigNumber.lessThan(0)) {
  2230          return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  2231      }
  2232      return bigNumber;
  2233  };
  2234  
  2235  /**
  2236   * Checks if the given string is strictly an address
  2237   *
  2238   * @method isStrictAddress
  2239   * @param {String} address the given HEX adress
  2240   * @return {Boolean}
  2241  */
  2242  var isStrictAddress = function (address) {
  2243      return /^0x[0-9a-f]{40}$/i.test(address);
  2244  };
  2245  
  2246  /**
  2247   * Checks if the given string is an address
  2248   *
  2249   * @method isAddress
  2250   * @param {String} address the given HEX adress
  2251   * @return {Boolean}
  2252  */
  2253  var isAddress = function (address) {
  2254      // if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2255      //     // check if it has the basic requirements of an address
  2256      //     return false;
  2257      // } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2258      //     // If it's all small caps or all all caps, return true
  2259      //     return true;
  2260      // } else {
  2261      //     // Otherwise check each case
  2262      //     return isChecksumAddress(address);
  2263      // }
  2264    if (!isString(address)){
  2265        return false
  2266      }else if (address.length !== 32){
  2267        return false
  2268      }else if (address.substr(0, 4) !== "NEAT"){
  2269        return false
  2270      }
  2271      return true
  2272  };
  2273  
  2274  /**
  2275   * Checks if the given string is a checksummed address
  2276   *
  2277   * @method isChecksumAddress
  2278   * @param {String} address the given HEX adress
  2279   * @return {Boolean}
  2280  */
  2281  var isChecksumAddress = function (address) {
  2282      // Check each case
  2283      address = address.replace('0x','');
  2284      var addressHash = sha3(address.toLowerCase());
  2285  
  2286      for (var i = 0; i < 40; i++ ) {
  2287          // the nth letter should be uppercase if the nth digit of casemap is 1
  2288          if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2289              return false;
  2290          }
  2291      }
  2292      return true;
  2293  };
  2294  
  2295  
  2296  
  2297  /**
  2298   * Makes a checksum address
  2299   *
  2300   * @method toChecksumAddress
  2301   * @param {String} address the given HEX adress
  2302   * @return {String}
  2303  */
  2304  var toChecksumAddress = function (address) {
  2305      if (typeof address === 'undefined') return '';
  2306  
  2307      address = address.toLowerCase().replace('0x','');
  2308      var addressHash = sha3(address);
  2309      var checksumAddress = '0x';
  2310  
  2311      for (var i = 0; i < address.length; i++ ) {
  2312          // If ith character is 9 to f then make it uppercase
  2313          if (parseInt(addressHash[i], 16) > 7) {
  2314            checksumAddress += address[i].toUpperCase();
  2315          } else {
  2316              checksumAddress += address[i];
  2317          }
  2318      }
  2319      return checksumAddress;
  2320  };
  2321  
  2322  /**
  2323   * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2324   *
  2325   * @method toAddress
  2326   * @param {String} address
  2327   * @return {String} formatted address
  2328   */
  2329  var toAddress = function (address) {
  2330      if (isStrictAddress(address)) {
  2331          return address;
  2332      }
  2333  
  2334      if (/^[0-9a-f]{40}$/.test(address)) {
  2335          return '0x' + address;
  2336      }
  2337  
  2338      return '0x' + padLeft(toHex(address).substr(2), 40);
  2339  };
  2340  
  2341  /**
  2342   * Returns true if object is BigNumber, otherwise false
  2343   *
  2344   * @method isBigNumber
  2345   * @param {Object}
  2346   * @return {Boolean}
  2347   */
  2348  var isBigNumber = function (object) {
  2349      return object instanceof BigNumber ||
  2350          (object && object.constructor && object.constructor.name === 'BigNumber');
  2351  };
  2352  
  2353  /**
  2354   * Returns true if object is string, otherwise false
  2355   *
  2356   * @method isString
  2357   * @param {Object}
  2358   * @return {Boolean}
  2359   */
  2360  var isString = function (object) {
  2361      return typeof object === 'string' ||
  2362          (object && object.constructor && object.constructor.name === 'String');
  2363  };
  2364  
  2365  /**
  2366   * Returns true if object is function, otherwise false
  2367   *
  2368   * @method isFunction
  2369   * @param {Object}
  2370   * @return {Boolean}
  2371   */
  2372  var isFunction = function (object) {
  2373      return typeof object === 'function';
  2374  };
  2375  
  2376  /**
  2377   * Returns true if object is Objet, otherwise false
  2378   *
  2379   * @method isObject
  2380   * @param {Object}
  2381   * @return {Boolean}
  2382   */
  2383  var isObject = function (object) {
  2384      return object !== null && !(object instanceof Array) && typeof object === 'object';
  2385  };
  2386  
  2387  /**
  2388   * Returns true if object is boolean, otherwise false
  2389   *
  2390   * @method isBoolean
  2391   * @param {Object}
  2392   * @return {Boolean}
  2393   */
  2394  var isBoolean = function (object) {
  2395      return typeof object === 'boolean';
  2396  };
  2397  
  2398  /**
  2399   * Returns true if object is array, otherwise false
  2400   *
  2401   * @method isArray
  2402   * @param {Object}
  2403   * @return {Boolean}
  2404   */
  2405  var isArray = function (object) {
  2406      return object instanceof Array;
  2407  };
  2408  
  2409  /**
  2410   * Returns true if given string is valid json object
  2411   *
  2412   * @method isJson
  2413   * @param {String}
  2414   * @return {Boolean}
  2415   */
  2416  var isJson = function (str) {
  2417      try {
  2418          return !!JSON.parse(str);
  2419      } catch (e) {
  2420          return false;
  2421      }
  2422  };
  2423  
  2424  /**
  2425   * Returns true if given string is a valid Ethereum block header bloom.
  2426   *
  2427   * @method isBloom
  2428   * @param {String} hex encoded bloom filter
  2429   * @return {Boolean}
  2430   */
  2431  var isBloom = function (bloom) {
  2432      if (!/^(0x)?[0-9a-f]{512}$/i.test(bloom)) {
  2433          return false;
  2434      } else if (/^(0x)?[0-9a-f]{512}$/.test(bloom) || /^(0x)?[0-9A-F]{512}$/.test(bloom)) {
  2435          return true;
  2436      }
  2437      return false;
  2438  };
  2439  
  2440  /**
  2441   * Returns true if given string is a valid log topic.
  2442   *
  2443   * @method isTopic
  2444   * @param {String} hex encoded topic
  2445   * @return {Boolean}
  2446   */
  2447  var isTopic = function (topic) {
  2448      if (!/^(0x)?[0-9a-f]{64}$/i.test(topic)) {
  2449          return false;
  2450      } else if (/^(0x)?[0-9a-f]{64}$/.test(topic) || /^(0x)?[0-9A-F]{64}$/.test(topic)) {
  2451          return true;
  2452      }
  2453      return false;
  2454  };
  2455  
  2456  module.exports = {
  2457      padLeft: padLeft,
  2458      padRight: padRight,
  2459      toHex: toHex,
  2460      toDecimal: toDecimal,
  2461      fromDecimal: fromDecimal,
  2462      toUtf8: toUtf8,
  2463      toAscii: toAscii,
  2464      fromUtf8: fromUtf8,
  2465      fromAscii: fromAscii,
  2466      transformToFullName: transformToFullName,
  2467      extractDisplayName: extractDisplayName,
  2468      extractTypeName: extractTypeName,
  2469      toWei: toWei,
  2470      fromWei: fromWei,
  2471      toBigNumber: toBigNumber,
  2472      toTwosComplement: toTwosComplement,
  2473      toAddress: toAddress,
  2474      isBigNumber: isBigNumber,
  2475      isStrictAddress: isStrictAddress,
  2476      isAddress: isAddress,
  2477      isChecksumAddress: isChecksumAddress,
  2478      toChecksumAddress: toChecksumAddress,
  2479      isFunction: isFunction,
  2480      isString: isString,
  2481      isObject: isObject,
  2482      isBoolean: isBoolean,
  2483      isArray: isArray,
  2484      isJson: isJson,
  2485      isBloom: isBloom,
  2486      isTopic: isTopic,
  2487  };
  2488  
  2489  },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
  2490  module.exports={
  2491      "version": "0.20.1"
  2492  }
  2493  
  2494  },{}],22:[function(require,module,exports){
  2495  /*
  2496      This file is part of web3.js.
  2497  
  2498      web3.js is free software: you can redistribute it and/or modify
  2499      it under the terms of the GNU Lesser General Public License as published by
  2500      the Free Software Foundation, either version 3 of the License, or
  2501      (at your option) any later version.
  2502  
  2503      web3.js is distributed in the hope that it will be useful,
  2504      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2505      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2506      GNU Lesser General Public License for more details.
  2507  
  2508      You should have received a copy of the GNU Lesser General Public License
  2509      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2510  */
  2511  /**
  2512   * @file web3.js
  2513   * @authors:
  2514   *   Jeffrey Wilcke <jeff@ethdev.com>
  2515   *   Marek Kotewicz <marek@ethdev.com>
  2516   *   Marian Oancea <marian@ethdev.com>
  2517   *   Fabian Vogelsteller <fabian@ethdev.com>
  2518   *   Gav Wood <g@ethdev.com>
  2519   * @date 2014
  2520   */
  2521  
  2522  var RequestManager = require('./web3/requestmanager');
  2523  var Iban = require('./web3/iban');
  2524  var Eth = require('./web3/methods/eth');
  2525  var DB = require('./web3/methods/db');
  2526  var Shh = require('./web3/methods/shh');
  2527  var Net = require('./web3/methods/net');
  2528  var Personal = require('./web3/methods/personal');
  2529  var Swarm = require('./web3/methods/swarm');
  2530  var Settings = require('./web3/settings');
  2531  var version = require('./version.json');
  2532  var utils = require('./utils/utils');
  2533  var sha3 = require('./utils/sha3');
  2534  var extend = require('./web3/extend');
  2535  var Batch = require('./web3/batch');
  2536  var Property = require('./web3/property');
  2537  var HttpProvider = require('./web3/httpprovider');
  2538  var IpcProvider = require('./web3/ipcprovider');
  2539  var BigNumber = require('bignumber.js');
  2540  
  2541  
  2542  
  2543  function Web3 (provider) {
  2544      this._requestManager = new RequestManager(provider);
  2545      this.currentProvider = provider;
  2546      this.eth = new Eth(this);
  2547      this.neat = new Eth(this);
  2548      this.db = new DB(this);
  2549      this.shh = new Shh(this);
  2550      this.net = new Net(this);
  2551      this.personal = new Personal(this);
  2552      this.bzz = new Swarm(this);
  2553      this.settings = new Settings();
  2554      this.version = {
  2555          api: version.version
  2556      };
  2557      this.providers = {
  2558          HttpProvider: HttpProvider,
  2559          IpcProvider: IpcProvider
  2560      };
  2561      this._extend = extend(this);
  2562      this._extend({
  2563          properties: properties()
  2564      });
  2565  }
  2566  
  2567  // expose providers on the class
  2568  Web3.providers = {
  2569      HttpProvider: HttpProvider,
  2570      IpcProvider: IpcProvider
  2571  };
  2572  
  2573  Web3.prototype.setProvider = function (provider) {
  2574      this._requestManager.setProvider(provider);
  2575      this.currentProvider = provider;
  2576  };
  2577  
  2578  Web3.prototype.reset = function (keepIsSyncing) {
  2579      this._requestManager.reset(keepIsSyncing);
  2580      this.settings = new Settings();
  2581  };
  2582  
  2583  Web3.prototype.BigNumber = BigNumber;
  2584  Web3.prototype.toHex = utils.toHex;
  2585  Web3.prototype.toAscii = utils.toAscii;
  2586  Web3.prototype.toUtf8 = utils.toUtf8;
  2587  Web3.prototype.fromAscii = utils.fromAscii;
  2588  Web3.prototype.fromUtf8 = utils.fromUtf8;
  2589  Web3.prototype.toDecimal = utils.toDecimal;
  2590  Web3.prototype.fromDecimal = utils.fromDecimal;
  2591  Web3.prototype.toBigNumber = utils.toBigNumber;
  2592  Web3.prototype.toWei = utils.toWei;
  2593  Web3.prototype.fromWei = utils.fromWei;
  2594  Web3.prototype.isAddress = utils.isAddress;
  2595  Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2596  Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2597  Web3.prototype.isIBAN = utils.isIBAN;
  2598  Web3.prototype.padLeft = utils.padLeft;
  2599  Web3.prototype.padRight = utils.padRight;
  2600  
  2601  Web3.prototype.getVoteHash =  function(from,pubKey,amount,salt){
  2602    if(pubKey.substr(0, 2) === '0x') pubKey = pubKey.substr(2);
  2603  
  2604    if( (typeof amount) == "string" && amount.substr(0, 2) === '0x'){
  2605      amount = amount.substr(2);
  2606    }else{
  2607      amount = amount.toString("16");
  2608    }
  2609    // like add on 2019年10月21日
  2610    var fromCode = "";
  2611    for(var i =0; i < from.length; i++){
  2612      fromCode += from[i].charCodeAt().toString('16');
  2613    }
  2614  
  2615    amount = (amount.length%2 == 0)?amount:("0"+amount);
  2616  
  2617    var saltCode = "";
  2618    for(var i=0;i<salt.length;i++){
  2619      saltCode += salt[i].charCodeAt().toString("16");
  2620    }
  2621  
  2622    var  concatString = fromCode+pubKey+amount+saltCode;
  2623  
  2624    return "0x" + sha3(concatString.toLowerCase(),{encoding: 'hex'});
  2625  };
  2626  
  2627  Web3.prototype.sha3 = function(string, options) {
  2628      return '0x' + sha3(string, options);
  2629  };
  2630  
  2631  /**
  2632   * Transforms direct icap to address
  2633   */
  2634  Web3.prototype.fromICAP = function (icap) {
  2635      var iban = new Iban(icap);
  2636      return iban.address();
  2637  };
  2638  
  2639  var properties = function () {
  2640      return [
  2641          new Property({
  2642              name: 'version.node',
  2643              getter: 'web3_clientVersion'
  2644          }),
  2645          new Property({
  2646              name: 'version.network',
  2647              getter: 'net_version',
  2648              inputFormatter: utils.toDecimal
  2649          }),
  2650          new Property({
  2651              name: 'version.ethereum',
  2652              getter: 'eth_protocolVersion',
  2653              inputFormatter: utils.toDecimal
  2654          }),
  2655          new Property({
  2656              name: 'version.whisper',
  2657              getter: 'shh_version',
  2658              inputFormatter: utils.toDecimal
  2659          })
  2660      ];
  2661  };
  2662  
  2663  Web3.prototype.isConnected = function(){
  2664      return (this.currentProvider && this.currentProvider.isConnected());
  2665  };
  2666  
  2667  Web3.prototype.createBatch = function () {
  2668      return new Batch(this);
  2669  };
  2670  
  2671  module.exports = Web3;
  2672  
  2673  
  2674  },{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
  2675  /*
  2676      This file is part of web3.js.
  2677  
  2678      web3.js is free software: you can redistribute it and/or modify
  2679      it under the terms of the GNU Lesser General Public License as published by
  2680      the Free Software Foundation, either version 3 of the License, or
  2681      (at your option) any later version.
  2682  
  2683      web3.js is distributed in the hope that it will be useful,
  2684      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2685      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2686      GNU Lesser General Public License for more details.
  2687  
  2688      You should have received a copy of the GNU Lesser General Public License
  2689      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2690  */
  2691  /**
  2692   * @file allevents.js
  2693   * @author Marek Kotewicz <marek@ethdev.com>
  2694   * @date 2014
  2695   */
  2696  
  2697  var sha3 = require('../utils/sha3');
  2698  var SolidityEvent = require('./event');
  2699  var formatters = require('./formatters');
  2700  var utils = require('../utils/utils');
  2701  var Filter = require('./filter');
  2702  var watches = require('./methods/watches');
  2703  
  2704  var AllSolidityEvents = function (requestManager, json, address) {
  2705      this._requestManager = requestManager;
  2706      this._json = json;
  2707      this._address = address;
  2708  };
  2709  
  2710  AllSolidityEvents.prototype.encode = function (options) {
  2711      options = options || {};
  2712      var result = {};
  2713  
  2714      ['fromBlock', 'toBlock'].filter(function (f) {
  2715          return options[f] !== undefined;
  2716      }).forEach(function (f) {
  2717          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2718      });
  2719  
  2720      result.address = this._address;
  2721  
  2722      return result;
  2723  };
  2724  
  2725  AllSolidityEvents.prototype.decode = function (data) {
  2726      data.data = data.data || '';
  2727      data.topics = data.topics || [];
  2728  
  2729      var eventTopic = data.topics[0].slice(2);
  2730      var match = this._json.filter(function (j) {
  2731          return eventTopic === sha3(utils.transformToFullName(j));
  2732      })[0];
  2733  
  2734      if (!match) { // cannot find matching event?
  2735          console.warn('cannot find event for log');
  2736          return data;
  2737      }
  2738  
  2739      var event = new SolidityEvent(this._requestManager, match, this._address);
  2740      return event.decode(data);
  2741  };
  2742  
  2743  AllSolidityEvents.prototype.execute = function (options, callback) {
  2744  
  2745      if (utils.isFunction(arguments[arguments.length - 1])) {
  2746          callback = arguments[arguments.length - 1];
  2747          if(arguments.length === 1)
  2748              options = null;
  2749      }
  2750  
  2751      var o = this.encode(options);
  2752      var formatter = this.decode.bind(this);
  2753      return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  2754  };
  2755  
  2756  AllSolidityEvents.prototype.attachToContract = function (contract) {
  2757      var execute = this.execute.bind(this);
  2758      contract.allEvents = execute;
  2759  };
  2760  
  2761  module.exports = AllSolidityEvents;
  2762  
  2763  
  2764  },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
  2765  /*
  2766      This file is part of web3.js.
  2767  
  2768      web3.js is free software: you can redistribute it and/or modify
  2769      it under the terms of the GNU Lesser General Public License as published by
  2770      the Free Software Foundation, either version 3 of the License, or
  2771      (at your option) any later version.
  2772  
  2773      web3.js is distributed in the hope that it will be useful,
  2774      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2775      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2776      GNU Lesser General Public License for more details.
  2777  
  2778      You should have received a copy of the GNU Lesser General Public License
  2779      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2780  */
  2781  /** 
  2782   * @file batch.js
  2783   * @author Marek Kotewicz <marek@ethdev.com>
  2784   * @date 2015
  2785   */
  2786  
  2787  var Jsonrpc = require('./jsonrpc');
  2788  var errors = require('./errors');
  2789  
  2790  var Batch = function (web3) {
  2791      this.requestManager = web3._requestManager;
  2792      this.requests = [];
  2793  };
  2794  
  2795  /**
  2796   * Should be called to add create new request to batch request
  2797   *
  2798   * @method add
  2799   * @param {Object} jsonrpc requet object
  2800   */
  2801  Batch.prototype.add = function (request) {
  2802      this.requests.push(request);
  2803  };
  2804  
  2805  /**
  2806   * Should be called to execute batch request
  2807   *
  2808   * @method execute
  2809   */
  2810  Batch.prototype.execute = function () {
  2811      var requests = this.requests;
  2812      this.requestManager.sendBatch(requests, function (err, results) {
  2813          results = results || [];
  2814          requests.map(function (request, index) {
  2815              return results[index] || {};
  2816          }).forEach(function (result, index) {
  2817              if (requests[index].callback) {
  2818  
  2819                  if (!Jsonrpc.isValidResponse(result)) {
  2820                      return requests[index].callback(errors.InvalidResponse(result));
  2821                  }
  2822  
  2823                  requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2824              }
  2825          });
  2826      }); 
  2827  };
  2828  
  2829  module.exports = Batch;
  2830  
  2831  
  2832  },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2833  /*
  2834      This file is part of web3.js.
  2835  
  2836      web3.js is free software: you can redistribute it and/or modify
  2837      it under the terms of the GNU Lesser General Public License as published by
  2838      the Free Software Foundation, either version 3 of the License, or
  2839      (at your option) any later version.
  2840  
  2841      web3.js is distributed in the hope that it will be useful,
  2842      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2843      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2844      GNU Lesser General Public License for more details.
  2845  
  2846      You should have received a copy of the GNU Lesser General Public License
  2847      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2848  */
  2849  /**
  2850   * @file contract.js
  2851   * @author Marek Kotewicz <marek@ethdev.com>
  2852   * @date 2014
  2853   */
  2854  
  2855  var utils = require('../utils/utils');
  2856  var coder = require('../solidity/coder');
  2857  var SolidityEvent = require('./event');
  2858  var SolidityFunction = require('./function');
  2859  var AllEvents = require('./allevents');
  2860  
  2861  /**
  2862   * Should be called to encode constructor params
  2863   *
  2864   * @method encodeConstructorParams
  2865   * @param {Array} abi
  2866   * @param {Array} constructor params
  2867   */
  2868  var encodeConstructorParams = function (abi, params) {
  2869      return abi.filter(function (json) {
  2870          return json.type === 'constructor' && json.inputs.length === params.length;
  2871      }).map(function (json) {
  2872          return json.inputs.map(function (input) {
  2873              return input.type;
  2874          });
  2875      }).map(function (types) {
  2876          return coder.encodeParams(types, params);
  2877      })[0] || '';
  2878  };
  2879  
  2880  /**
  2881   * Should be called to add functions to contract object
  2882   *
  2883   * @method addFunctionsToContract
  2884   * @param {Contract} contract
  2885   * @param {Array} abi
  2886   */
  2887  var addFunctionsToContract = function (contract) {
  2888      contract.abi.filter(function (json) {
  2889          return json.type === 'function';
  2890      }).map(function (json) {
  2891          return new SolidityFunction(contract._eth, json, contract.address);
  2892      }).forEach(function (f) {
  2893          f.attachToContract(contract);
  2894      });
  2895  };
  2896  
  2897  /**
  2898   * Should be called to add events to contract object
  2899   *
  2900   * @method addEventsToContract
  2901   * @param {Contract} contract
  2902   * @param {Array} abi
  2903   */
  2904  var addEventsToContract = function (contract) {
  2905      var events = contract.abi.filter(function (json) {
  2906          return json.type === 'event';
  2907      });
  2908  
  2909      var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2910      All.attachToContract(contract);
  2911  
  2912      events.map(function (json) {
  2913          return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2914      }).forEach(function (e) {
  2915          e.attachToContract(contract);
  2916      });
  2917  };
  2918  
  2919  
  2920  /**
  2921   * Should be called to check if the contract gets properly deployed on the blockchain.
  2922   *
  2923   * @method checkForContractAddress
  2924   * @param {Object} contract
  2925   * @param {Function} callback
  2926   * @returns {Undefined}
  2927   */
  2928  var checkForContractAddress = function(contract, callback){
  2929      var count = 0,
  2930          callbackFired = false;
  2931  
  2932      // wait for receipt
  2933      var filter = contract._eth.filter('latest', function(e){
  2934          if (!e && !callbackFired) {
  2935              count++;
  2936  
  2937              // stop watching after 50 blocks (timeout)
  2938              if (count > 50) {
  2939  
  2940                  filter.stopWatching(function() {});
  2941                  callbackFired = true;
  2942  
  2943                  if (callback)
  2944                      callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2945                  else
  2946                      throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2947  
  2948  
  2949              } else {
  2950  
  2951                  contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2952                      if(receipt && !callbackFired) {
  2953  
  2954                          contract._eth.getCode(receipt.contractAddress, function(e, code){
  2955                              /*jshint maxcomplexity: 6 */
  2956  
  2957                              if(callbackFired || !code)
  2958                                  return;
  2959  
  2960                              filter.stopWatching(function() {});
  2961                              callbackFired = true;
  2962  
  2963                              if(code.length > 3) {
  2964  
  2965                                  // console.log('Contract code deployed!');
  2966  
  2967                                  contract.address = receipt.contractAddress;
  2968  
  2969                                  // attach events and methods again after we have
  2970                                  addFunctionsToContract(contract);
  2971                                  addEventsToContract(contract);
  2972  
  2973                                  // call callback for the second time
  2974                                  if(callback)
  2975                                      callback(null, contract);
  2976  
  2977                              } else {
  2978                                  if(callback)
  2979                                      callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2980                                  else
  2981                                      throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2982                              }
  2983                          });
  2984                      }
  2985                  });
  2986              }
  2987          }
  2988      });
  2989  };
  2990  
  2991  /**
  2992   * Should be called to create new ContractFactory instance
  2993   *
  2994   * @method ContractFactory
  2995   * @param {Array} abi
  2996   */
  2997  var ContractFactory = function (eth, abi) {
  2998      this.eth = eth;
  2999      this.abi = abi;
  3000  
  3001      /**
  3002       * Should be called to create new contract on a blockchain
  3003       *
  3004       * @method new
  3005       * @param {Any} contract constructor param1 (optional)
  3006       * @param {Any} contract constructor param2 (optional)
  3007       * @param {Object} contract transaction object (required)
  3008       * @param {Function} callback
  3009       * @returns {Contract} returns contract instance
  3010       */
  3011      this.new = function () {
  3012          /*jshint maxcomplexity: 7 */
  3013          
  3014          var contract = new Contract(this.eth, this.abi);
  3015  
  3016          // parse arguments
  3017          var options = {}; // required!
  3018          var callback;
  3019  
  3020          var args = Array.prototype.slice.call(arguments);
  3021          if (utils.isFunction(args[args.length - 1])) {
  3022              callback = args.pop();
  3023          }
  3024  
  3025          var last = args[args.length - 1];
  3026          if (utils.isObject(last) && !utils.isArray(last)) {
  3027              options = args.pop();
  3028          }
  3029  
  3030          if (options.value > 0) {
  3031              var constructorAbi = abi.filter(function (json) {
  3032                  return json.type === 'constructor' && json.inputs.length === args.length;
  3033              })[0] || {};
  3034  
  3035              if (!constructorAbi.payable) {
  3036                  throw new Error('Cannot send value to non-payable constructor');
  3037              }
  3038          }
  3039  
  3040          var bytes = encodeConstructorParams(this.abi, args);
  3041          options.data += bytes;
  3042  
  3043          if (callback) {
  3044  
  3045              // wait for the contract address adn check if the code was deployed
  3046              this.eth.sendTransaction(options, function (err, hash) {
  3047                  if (err) {
  3048                      callback(err);
  3049                  } else {
  3050                      // add the transaction hash
  3051                      contract.transactionHash = hash;
  3052  
  3053                      // call callback for the first time
  3054                      callback(null, contract);
  3055  
  3056                      checkForContractAddress(contract, callback);
  3057                  }
  3058              });
  3059          } else {
  3060              var hash = this.eth.sendTransaction(options);
  3061              // add the transaction hash
  3062              contract.transactionHash = hash;
  3063              checkForContractAddress(contract);
  3064          }
  3065  
  3066          return contract;
  3067      };
  3068  
  3069      this.new.getData = this.getData.bind(this);
  3070  };
  3071  
  3072  /**
  3073   * Should be called to create new ContractFactory
  3074   *
  3075   * @method contract
  3076   * @param {Array} abi
  3077   * @returns {ContractFactory} new contract factory
  3078   */
  3079  //var contract = function (abi) {
  3080      //return new ContractFactory(abi);
  3081  //};
  3082  
  3083  
  3084  
  3085  /**
  3086   * Should be called to get access to existing contract on a blockchain
  3087   *
  3088   * @method at
  3089   * @param {Address} contract address (required)
  3090   * @param {Function} callback {optional)
  3091   * @returns {Contract} returns contract if no callback was passed,
  3092   * otherwise calls callback function (err, contract)
  3093   */
  3094  ContractFactory.prototype.at = function (address, callback) {
  3095      var contract = new Contract(this.eth, this.abi, address);
  3096  
  3097      // this functions are not part of prototype,
  3098      // because we dont want to spoil the interface
  3099      addFunctionsToContract(contract);
  3100      addEventsToContract(contract);
  3101  
  3102      if (callback) {
  3103          callback(null, contract);
  3104      }
  3105      return contract;
  3106  };
  3107  
  3108  /**
  3109   * Gets the data, which is data to deploy plus constructor params
  3110   *
  3111   * @method getData
  3112   */
  3113  ContractFactory.prototype.getData = function () {
  3114      var options = {}; // required!
  3115      var args = Array.prototype.slice.call(arguments);
  3116  
  3117      var last = args[args.length - 1];
  3118      if (utils.isObject(last) && !utils.isArray(last)) {
  3119          options = args.pop();
  3120      }
  3121  
  3122      var bytes = encodeConstructorParams(this.abi, args);
  3123      options.data += bytes;
  3124  
  3125      return options.data;
  3126  };
  3127  
  3128  /**
  3129   * Should be called to create new contract instance
  3130   *
  3131   * @method Contract
  3132   * @param {Array} abi
  3133   * @param {Address} contract address
  3134   */
  3135  var Contract = function (eth, abi, address) {
  3136      this._eth = eth;
  3137      this.transactionHash = null;
  3138      this.address = address;
  3139      this.abi = abi;
  3140  };
  3141  
  3142  module.exports = ContractFactory;
  3143  
  3144  },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  3145  /*
  3146      This file is part of web3.js.
  3147  
  3148      web3.js is free software: you can redistribute it and/or modify
  3149      it under the terms of the GNU Lesser General Public License as published by
  3150      the Free Software Foundation, either version 3 of the License, or
  3151      (at your option) any later version.
  3152  
  3153      web3.js is distributed in the hope that it will be useful,
  3154      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3155      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3156      GNU Lesser General Public License for more details.
  3157  
  3158      You should have received a copy of the GNU Lesser General Public License
  3159      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3160  */
  3161  /** 
  3162   * @file errors.js
  3163   * @author Marek Kotewicz <marek@ethdev.com>
  3164   * @date 2015
  3165   */
  3166  
  3167  module.exports = {
  3168      InvalidNumberOfSolidityArgs: function () {
  3169          return new Error('Invalid number of arguments to Solidity function');
  3170      },
  3171      InvalidNumberOfRPCParams: function () {
  3172          return new Error('Invalid number of input parameters to RPC method');
  3173      },
  3174      InvalidConnection: function (host){
  3175          return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  3176      },
  3177      InvalidProvider: function () {
  3178          return new Error('Provider not set or invalid');
  3179      },
  3180      InvalidResponse: function (result){
  3181          var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  3182          return new Error(message);
  3183      },
  3184      ConnectionTimeout: function (ms){
  3185          return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
  3186      }
  3187  };
  3188  
  3189  },{}],27:[function(require,module,exports){
  3190  /*
  3191      This file is part of web3.js.
  3192  
  3193      web3.js is free software: you can redistribute it and/or modify
  3194      it under the terms of the GNU Lesser General Public License as published by
  3195      the Free Software Foundation, either version 3 of the License, or
  3196      (at your option) any later version.
  3197  
  3198      web3.js is distributed in the hope that it will be useful,
  3199      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3200      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3201      GNU Lesser General Public License for more details.
  3202  
  3203      You should have received a copy of the GNU Lesser General Public License
  3204      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3205  */
  3206  /**
  3207   * @file event.js
  3208   * @author Marek Kotewicz <marek@ethdev.com>
  3209   * @date 2014
  3210   */
  3211  
  3212  var utils = require('../utils/utils');
  3213  var coder = require('../solidity/coder');
  3214  var formatters = require('./formatters');
  3215  var sha3 = require('../utils/sha3');
  3216  var Filter = require('./filter');
  3217  var watches = require('./methods/watches');
  3218  
  3219  /**
  3220   * This prototype should be used to create event filters
  3221   */
  3222  var SolidityEvent = function (requestManager, json, address) {
  3223      this._requestManager = requestManager;
  3224      this._params = json.inputs;
  3225      this._name = utils.transformToFullName(json);
  3226      this._address = address;
  3227      this._anonymous = json.anonymous;
  3228  };
  3229  
  3230  /**
  3231   * Should be used to get filtered param types
  3232   *
  3233   * @method types
  3234   * @param {Bool} decide if returned typed should be indexed
  3235   * @return {Array} array of types
  3236   */
  3237  SolidityEvent.prototype.types = function (indexed) {
  3238      return this._params.filter(function (i) {
  3239          return i.indexed === indexed;
  3240      }).map(function (i) {
  3241          return i.type;
  3242      });
  3243  };
  3244  
  3245  /**
  3246   * Should be used to get event display name
  3247   *
  3248   * @method displayName
  3249   * @return {String} event display name
  3250   */
  3251  SolidityEvent.prototype.displayName = function () {
  3252      return utils.extractDisplayName(this._name);
  3253  };
  3254  
  3255  /**
  3256   * Should be used to get event type name
  3257   *
  3258   * @method typeName
  3259   * @return {String} event type name
  3260   */
  3261  SolidityEvent.prototype.typeName = function () {
  3262      return utils.extractTypeName(this._name);
  3263  };
  3264  
  3265  /**
  3266   * Should be used to get event signature
  3267   *
  3268   * @method signature
  3269   * @return {String} event signature
  3270   */
  3271  SolidityEvent.prototype.signature = function () {
  3272      return sha3(this._name);
  3273  };
  3274  
  3275  /**
  3276   * Should be used to encode indexed params and options to one final object
  3277   *
  3278   * @method encode
  3279   * @param {Object} indexed
  3280   * @param {Object} options
  3281   * @return {Object} everything combined together and encoded
  3282   */
  3283  SolidityEvent.prototype.encode = function (indexed, options) {
  3284      indexed = indexed || {};
  3285      options = options || {};
  3286      var result = {};
  3287  
  3288      ['fromBlock', 'toBlock'].filter(function (f) {
  3289          return options[f] !== undefined;
  3290      }).forEach(function (f) {
  3291          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  3292      });
  3293  
  3294      result.topics = [];
  3295  
  3296      result.address = this._address;
  3297      if (!this._anonymous) {
  3298          result.topics.push('0x' + this.signature());
  3299      }
  3300  
  3301      var indexedTopics = this._params.filter(function (i) {
  3302          return i.indexed === true;
  3303      }).map(function (i) {
  3304          var value = indexed[i.name];
  3305          if (value === undefined || value === null) {
  3306              return null;
  3307          }
  3308  
  3309          if (utils.isArray(value)) {
  3310              return value.map(function (v) {
  3311                  return '0x' + coder.encodeParam(i.type, v);
  3312              });
  3313          }
  3314          return '0x' + coder.encodeParam(i.type, value);
  3315      });
  3316  
  3317      result.topics = result.topics.concat(indexedTopics);
  3318  
  3319      return result;
  3320  };
  3321  
  3322  /**
  3323   * Should be used to decode indexed params and options
  3324   *
  3325   * @method decode
  3326   * @param {Object} data
  3327   * @return {Object} result object with decoded indexed && not indexed params
  3328   */
  3329  SolidityEvent.prototype.decode = function (data) {
  3330  
  3331      data.data = data.data || '';
  3332      data.topics = data.topics || [];
  3333  
  3334      var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  3335      var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  3336      var indexedParams = coder.decodeParams(this.types(true), indexedData);
  3337  
  3338      var notIndexedData = data.data.slice(2);
  3339      var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  3340  
  3341      var result = formatters.outputLogFormatter(data);
  3342      result.event = this.displayName();
  3343      result.address = data.address;
  3344  
  3345      result.args = this._params.reduce(function (acc, current) {
  3346          acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  3347          return acc;
  3348      }, {});
  3349  
  3350      delete result.data;
  3351      delete result.topics;
  3352  
  3353      return result;
  3354  };
  3355  
  3356  /**
  3357   * Should be used to create new filter object from event
  3358   *
  3359   * @method execute
  3360   * @param {Object} indexed
  3361   * @param {Object} options
  3362   * @return {Object} filter object
  3363   */
  3364  SolidityEvent.prototype.execute = function (indexed, options, callback) {
  3365  
  3366      if (utils.isFunction(arguments[arguments.length - 1])) {
  3367          callback = arguments[arguments.length - 1];
  3368          if(arguments.length === 2)
  3369              options = null;
  3370          if(arguments.length === 1) {
  3371              options = null;
  3372              indexed = {};
  3373          }
  3374      }
  3375  
  3376      var o = this.encode(indexed, options);
  3377      var formatter = this.decode.bind(this);
  3378      return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  3379  };
  3380  
  3381  /**
  3382   * Should be used to attach event to contract object
  3383   *
  3384   * @method attachToContract
  3385   * @param {Contract}
  3386   */
  3387  SolidityEvent.prototype.attachToContract = function (contract) {
  3388      var execute = this.execute.bind(this);
  3389      var displayName = this.displayName();
  3390      if (!contract[displayName]) {
  3391          contract[displayName] = execute;
  3392      }
  3393      contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  3394  };
  3395  
  3396  module.exports = SolidityEvent;
  3397  
  3398  
  3399  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
  3400  var formatters = require('./formatters');
  3401  var utils = require('./../utils/utils');
  3402  var Method = require('./method');
  3403  var Property = require('./property');
  3404  
  3405  // TODO: refactor, so the input params are not altered.
  3406  // it's necessary to make same 'extension' work with multiple providers
  3407  var extend = function (web3) {
  3408      /* jshint maxcomplexity:5 */
  3409      var ex = function (extension) {
  3410  
  3411          var extendedObject;
  3412          if (extension.property) {
  3413              if (!web3[extension.property]) {
  3414                  web3[extension.property] = {};
  3415              }
  3416              extendedObject = web3[extension.property];
  3417          } else {
  3418              extendedObject = web3;
  3419          }
  3420  
  3421          if (extension.methods) {
  3422              extension.methods.forEach(function (method) {
  3423                  method.attachToObject(extendedObject);
  3424                  method.setRequestManager(web3._requestManager);
  3425              });
  3426          }
  3427  
  3428          if (extension.properties) {
  3429              extension.properties.forEach(function (property) {
  3430                  property.attachToObject(extendedObject);
  3431                  property.setRequestManager(web3._requestManager);
  3432              });
  3433          }
  3434      };
  3435  
  3436      ex.formatters = formatters; 
  3437      ex.utils = utils;
  3438      ex.Method = Method;
  3439      ex.Property = Property;
  3440  
  3441      return ex;
  3442  };
  3443  
  3444  
  3445  
  3446  module.exports = extend;
  3447  
  3448  
  3449  },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
  3450  /*
  3451      This file is part of web3.js.
  3452  
  3453      web3.js is free software: you can redistribute it and/or modify
  3454      it under the terms of the GNU Lesser General Public License as published by
  3455      the Free Software Foundation, either version 3 of the License, or
  3456      (at your option) any later version.
  3457  
  3458      web3.js is distributed in the hope that it will be useful,
  3459      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3460      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3461      GNU Lesser General Public License for more details.
  3462  
  3463      You should have received a copy of the GNU Lesser General Public License
  3464      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3465  */
  3466  /** @file filter.js
  3467   * @authors:
  3468   *   Jeffrey Wilcke <jeff@ethdev.com>
  3469   *   Marek Kotewicz <marek@ethdev.com>
  3470   *   Marian Oancea <marian@ethdev.com>
  3471   *   Fabian Vogelsteller <fabian@ethdev.com>
  3472   *   Gav Wood <g@ethdev.com>
  3473   * @date 2014
  3474   */
  3475  
  3476  var formatters = require('./formatters');
  3477  var utils = require('../utils/utils');
  3478  
  3479  /**
  3480  * Converts a given topic to a hex string, but also allows null values.
  3481  *
  3482  * @param {Mixed} value
  3483  * @return {String}
  3484  */
  3485  var toTopic = function(value){
  3486  
  3487      if(value === null || typeof value === 'undefined')
  3488          return null;
  3489  
  3490      value = String(value);
  3491  
  3492      if(value.indexOf('0x') === 0)
  3493          return value;
  3494      else
  3495          return utils.fromUtf8(value);
  3496  };
  3497  
  3498  /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3499  /// @param should be string or object
  3500  /// @returns options string or object
  3501  var getOptions = function (options, type) {
  3502      /*jshint maxcomplexity: 6 */
  3503  
  3504      if (utils.isString(options)) {
  3505          return options;
  3506      }
  3507  
  3508      options = options || {};
  3509  
  3510  
  3511      switch(type) {
  3512          case 'eth':
  3513  
  3514              // make sure topics, get converted to hex
  3515              options.topics = options.topics || [];
  3516              options.topics = options.topics.map(function(topic){
  3517                  return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3518              });
  3519  
  3520              return {
  3521                  topics: options.topics,
  3522                  from: options.from,
  3523                  to: options.to,
  3524                  address: options.address,
  3525                  fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3526                  toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3527              };
  3528          case 'shh':
  3529              return options;
  3530      }
  3531  };
  3532  
  3533  /**
  3534  Adds the callback and sets up the methods, to iterate over the results.
  3535  
  3536  @method getLogsAtStart
  3537  @param {Object} self
  3538  @param {function} callback
  3539  */
  3540  var getLogsAtStart = function(self, callback){
  3541      // call getFilterLogs for the first watch callback start
  3542      if (!utils.isString(self.options)) {
  3543          self.get(function (err, messages) {
  3544              // don't send all the responses to all the watches again... just to self one
  3545              if (err) {
  3546                  callback(err);
  3547              }
  3548  
  3549              if(utils.isArray(messages)) {
  3550                  messages.forEach(function (message) {
  3551                      callback(null, message);
  3552                  });
  3553              }
  3554          });
  3555      }
  3556  };
  3557  
  3558  /**
  3559  Adds the callback and sets up the methods, to iterate over the results.
  3560  
  3561  @method pollFilter
  3562  @param {Object} self
  3563  */
  3564  var pollFilter = function(self) {
  3565  
  3566      var onMessage = function (error, messages) {
  3567          if (error) {
  3568              return self.callbacks.forEach(function (callback) {
  3569                  callback(error);
  3570              });
  3571          }
  3572  
  3573          if(utils.isArray(messages)) {
  3574              messages.forEach(function (message) {
  3575                  message = self.formatter ? self.formatter(message) : message;
  3576                  self.callbacks.forEach(function (callback) {
  3577                      callback(null, message);
  3578                  });
  3579              });
  3580          }
  3581      };
  3582  
  3583      self.requestManager.startPolling({
  3584          method: self.implementation.poll.call,
  3585          params: [self.filterId],
  3586      }, self.filterId, onMessage, self.stopWatching.bind(self));
  3587  
  3588  };
  3589  
  3590  var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
  3591      var self = this;
  3592      var implementation = {};
  3593      methods.forEach(function (method) {
  3594          method.setRequestManager(requestManager);
  3595          method.attachToObject(implementation);
  3596      });
  3597      this.requestManager = requestManager;
  3598      this.options = getOptions(options, type);
  3599      this.implementation = implementation;
  3600      this.filterId = null;
  3601      this.callbacks = [];
  3602      this.getLogsCallbacks = [];
  3603      this.pollFilters = [];
  3604      this.formatter = formatter;
  3605      this.implementation.newFilter(this.options, function(error, id){
  3606          if(error) {
  3607              self.callbacks.forEach(function(cb){
  3608                  cb(error);
  3609              });
  3610              if (typeof filterCreationErrorCallback === 'function') {
  3611                filterCreationErrorCallback(error);
  3612              }
  3613          } else {
  3614              self.filterId = id;
  3615  
  3616              // check if there are get pending callbacks as a consequence
  3617              // of calling get() with filterId unassigned.
  3618              self.getLogsCallbacks.forEach(function (cb){
  3619                  self.get(cb);
  3620              });
  3621              self.getLogsCallbacks = [];
  3622  
  3623              // get filter logs for the already existing watch calls
  3624              self.callbacks.forEach(function(cb){
  3625                  getLogsAtStart(self, cb);
  3626              });
  3627              if(self.callbacks.length > 0)
  3628                  pollFilter(self);
  3629  
  3630              // start to watch immediately
  3631              if(typeof callback === 'function') {
  3632                  return self.watch(callback);
  3633              }
  3634          }
  3635      });
  3636  
  3637      return this;
  3638  };
  3639  
  3640  Filter.prototype.watch = function (callback) {
  3641      this.callbacks.push(callback);
  3642  
  3643      if(this.filterId) {
  3644          getLogsAtStart(this, callback);
  3645          pollFilter(this);
  3646      }
  3647  
  3648      return this;
  3649  };
  3650  
  3651  Filter.prototype.stopWatching = function (callback) {
  3652      this.requestManager.stopPolling(this.filterId);
  3653      this.callbacks = [];
  3654      // remove filter async
  3655      if (callback) {
  3656          this.implementation.uninstallFilter(this.filterId, callback);
  3657      } else {
  3658          return this.implementation.uninstallFilter(this.filterId);
  3659      }
  3660  };
  3661  
  3662  Filter.prototype.get = function (callback) {
  3663      var self = this;
  3664      if (utils.isFunction(callback)) {
  3665          if (this.filterId === null) {
  3666              // If filterId is not set yet, call it back
  3667              // when newFilter() assigns it.
  3668              this.getLogsCallbacks.push(callback);
  3669          } else {
  3670              this.implementation.getLogs(this.filterId, function(err, res){
  3671                  if (err) {
  3672                      callback(err);
  3673                  } else {
  3674                      callback(null, res.map(function (log) {
  3675                          return self.formatter ? self.formatter(log) : log;
  3676                      }));
  3677                  }
  3678              });
  3679          }
  3680      } else {
  3681          if (this.filterId === null) {
  3682              throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3683          }
  3684          var logs = this.implementation.getLogs(this.filterId);
  3685          return logs.map(function (log) {
  3686              return self.formatter ? self.formatter(log) : log;
  3687          });
  3688      }
  3689  
  3690      return this;
  3691  };
  3692  
  3693  module.exports = Filter;
  3694  
  3695  
  3696  },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3697  'use strict'
  3698  
  3699  /*
  3700      This file is part of web3.js.
  3701  
  3702      web3.js is free software: you can redistribute it and/or modify
  3703      it under the terms of the GNU Lesser General Public License as published by
  3704      the Free Software Foundation, either version 3 of the License, or
  3705      (at your option) any later version.
  3706  
  3707      web3.js is distributed in the hope that it will be useful,
  3708      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3709      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3710      GNU Lesser General Public License for more details.
  3711  
  3712      You should have received a copy of the GNU Lesser General Public License
  3713      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3714  */
  3715  /**
  3716   * @file formatters.js
  3717   * @author Marek Kotewicz <marek@ethdev.com>
  3718   * @author Fabian Vogelsteller <fabian@ethdev.com>
  3719   * @date 2015
  3720   */
  3721  
  3722  var utils = require('../utils/utils');
  3723  var config = require('../utils/config');
  3724  var Iban = require('./iban');
  3725  
  3726  /**
  3727   * Should the format output to a big number
  3728   *
  3729   * @method outputBigNumberFormatter
  3730   * @param {String|Number|BigNumber}
  3731   * @returns {BigNumber} object
  3732   */
  3733  var outputBigNumberFormatter = function (number) {
  3734      return utils.toBigNumber(number);
  3735  };
  3736  
  3737  var isPredefinedBlockNumber = function (blockNumber) {
  3738      return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3739  };
  3740  
  3741  var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3742      if (blockNumber === undefined) {
  3743          return config.defaultBlock;
  3744      }
  3745      return inputBlockNumberFormatter(blockNumber);
  3746  };
  3747  
  3748  var inputBlockNumberFormatter = function (blockNumber) {
  3749      if (blockNumber === undefined) {
  3750          return undefined;
  3751      } else if (isPredefinedBlockNumber(blockNumber)) {
  3752          return blockNumber;
  3753      }
  3754      return utils.toHex(blockNumber);
  3755  };
  3756  
  3757  /**
  3758   * Formats the input of a transaction and converts all values to HEX
  3759   *
  3760   * @method inputCallFormatter
  3761   * @param {Object} transaction options
  3762   * @returns object
  3763  */
  3764  var inputCallFormatter = function (options){
  3765  
  3766      options.from = options.from || config.defaultAccount;
  3767  
  3768      if (options.from) {
  3769          options.from = inputAddressFormatter(options.from);
  3770      }
  3771  
  3772      if (options.to) { // it might be contract creation
  3773          options.to = inputAddressFormatter(options.to);
  3774      }
  3775  
  3776      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3777          return options[key] !== undefined;
  3778      }).forEach(function(key){
  3779          options[key] = utils.fromDecimal(options[key]);
  3780      });
  3781  
  3782      return options;
  3783  };
  3784  
  3785  /**
  3786   * Formats the input of a transaction and converts all values to HEX
  3787   *
  3788   * @method inputTransactionFormatter
  3789   * @param {Object} transaction options
  3790   * @returns object
  3791  */
  3792  var inputTransactionFormatter = function (options){
  3793  
  3794      options.from = options.from || config.defaultAccount;
  3795      options.from = inputAddressFormatter(options.from);
  3796  
  3797      if (options.to) { // it might be contract creation
  3798          options.to = inputAddressFormatter(options.to);
  3799      }
  3800  
  3801      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3802          return options[key] !== undefined;
  3803      }).forEach(function(key){
  3804          options[key] = utils.fromDecimal(options[key]);
  3805      });
  3806  
  3807      return options;
  3808  };
  3809  
  3810  /**
  3811   * Formats the output of a transaction to its proper values
  3812   *
  3813   * @method outputTransactionFormatter
  3814   * @param {Object} tx
  3815   * @returns {Object}
  3816  */
  3817  var outputTransactionFormatter = function (tx){
  3818      if(tx.blockNumber !== null)
  3819          tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3820      if(tx.transactionIndex !== null)
  3821          tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3822      tx.nonce = utils.toDecimal(tx.nonce);
  3823      tx.gas = utils.toDecimal(tx.gas);
  3824      tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3825      tx.value = utils.toBigNumber(tx.value);
  3826      return tx;
  3827  };
  3828  
  3829  /**
  3830   * Formats the output of a transaction receipt to its proper values
  3831   *
  3832   * @method outputTransactionReceiptFormatter
  3833   * @param {Object} receipt
  3834   * @returns {Object}
  3835  */
  3836  var outputTransactionReceiptFormatter = function (receipt){
  3837      if(receipt.blockNumber !== null)
  3838          receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3839      if(receipt.transactionIndex !== null)
  3840          receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3841      receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3842      receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3843  
  3844      if(utils.isArray(receipt.logs)) {
  3845          receipt.logs = receipt.logs.map(function(log){
  3846              return outputLogFormatter(log);
  3847          });
  3848      }
  3849  
  3850      return receipt;
  3851  };
  3852  
  3853  /**
  3854   * Formats the output of a block to its proper values
  3855   *
  3856   * @method outputBlockFormatter
  3857   * @param {Object} block
  3858   * @returns {Object}
  3859  */
  3860  var outputBlockFormatter = function(block) {
  3861  
  3862      // transform to number
  3863      block.gasLimit = utils.toDecimal(block.gasLimit);
  3864      block.gasUsed = utils.toDecimal(block.gasUsed);
  3865      block.size = utils.toDecimal(block.size);
  3866      block.timestamp = utils.toDecimal(block.timestamp);
  3867      if(block.number !== null)
  3868          block.number = utils.toDecimal(block.number);
  3869  
  3870      block.difficulty = utils.toBigNumber(block.difficulty);
  3871      block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3872  
  3873      if (utils.isArray(block.transactions)) {
  3874          block.transactions.forEach(function(item){
  3875              if(!utils.isString(item))
  3876                  return outputTransactionFormatter(item);
  3877          });
  3878      }
  3879  
  3880      return block;
  3881  };
  3882  
  3883  /**
  3884   * Formats the output of a log
  3885   *
  3886   * @method outputLogFormatter
  3887   * @param {Object} log object
  3888   * @returns {Object} log
  3889  */
  3890  var outputLogFormatter = function(log) {
  3891      if(log.blockNumber)
  3892          log.blockNumber = utils.toDecimal(log.blockNumber);
  3893      if(log.transactionIndex)
  3894          log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3895      if(log.logIndex)
  3896          log.logIndex = utils.toDecimal(log.logIndex);
  3897  
  3898      return log;
  3899  };
  3900  
  3901  /**
  3902   * Formats the input of a whisper post and converts all values to HEX
  3903   *
  3904   * @method inputPostFormatter
  3905   * @param {Object} transaction object
  3906   * @returns {Object}
  3907  */
  3908  var inputPostFormatter = function(post) {
  3909  
  3910      // post.payload = utils.toHex(post.payload);
  3911      post.ttl = utils.fromDecimal(post.ttl);
  3912      post.workToProve = utils.fromDecimal(post.workToProve);
  3913      post.priority = utils.fromDecimal(post.priority);
  3914  
  3915      // fallback
  3916      if (!utils.isArray(post.topics)) {
  3917          post.topics = post.topics ? [post.topics] : [];
  3918      }
  3919  
  3920      // format the following options
  3921      post.topics = post.topics.map(function(topic){
  3922          // convert only if not hex
  3923          return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3924      });
  3925  
  3926      return post;
  3927  };
  3928  
  3929  /**
  3930   * Formats the output of a received post message
  3931   *
  3932   * @method outputPostFormatter
  3933   * @param {Object}
  3934   * @returns {Object}
  3935   */
  3936  var outputPostFormatter = function(post){
  3937  
  3938      post.expiry = utils.toDecimal(post.expiry);
  3939      post.sent = utils.toDecimal(post.sent);
  3940      post.ttl = utils.toDecimal(post.ttl);
  3941      post.workProved = utils.toDecimal(post.workProved);
  3942      // post.payloadRaw = post.payload;
  3943      // post.payload = utils.toAscii(post.payload);
  3944  
  3945      // if (utils.isJson(post.payload)) {
  3946      //     post.payload = JSON.parse(post.payload);
  3947      // }
  3948  
  3949      // format the following options
  3950      if (!post.topics) {
  3951          post.topics = [];
  3952      }
  3953      post.topics = post.topics.map(function(topic){
  3954          return utils.toAscii(topic);
  3955      });
  3956  
  3957      return post;
  3958  };
  3959  
  3960  var inputAddressFormatter = function (address) {
  3961      // var iban = new Iban(address);
  3962      // if (iban.isValid() && iban.isDirect()) {
  3963      //     return '0x' + iban.address();
  3964      // } else if (utils.isStrictAddress(address)) {
  3965      //     return address;
  3966      // } else if (utils.isAddress(address)) {
  3967      //     return '0x' + address;
  3968      // }
  3969  
  3970      if (!utils.isAddress(address)) {
  3971        throw new Error('invalid address');
  3972      }
  3973  
  3974      return address
  3975  };
  3976  
  3977  
  3978  
  3979  
  3980  var outputSyncingFormatter = function(result) {
  3981      if (!result) {
  3982          return result;
  3983      }
  3984  
  3985      result.startingBlock = utils.toDecimal(result.startingBlock);
  3986      result.currentBlock = utils.toDecimal(result.currentBlock);
  3987      result.highestBlock = utils.toDecimal(result.highestBlock);
  3988      if (result.knownStates) {
  3989          result.knownStates = utils.toDecimal(result.knownStates);
  3990          result.pulledStates = utils.toDecimal(result.pulledStates);
  3991      }
  3992  
  3993      return result;
  3994  };
  3995  
  3996  module.exports = {
  3997      inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3998      inputBlockNumberFormatter: inputBlockNumberFormatter,
  3999      inputCallFormatter: inputCallFormatter,
  4000      inputTransactionFormatter: inputTransactionFormatter,
  4001      inputAddressFormatter: inputAddressFormatter,
  4002      inputPostFormatter: inputPostFormatter,
  4003      outputBigNumberFormatter: outputBigNumberFormatter,
  4004      outputTransactionFormatter: outputTransactionFormatter,
  4005      outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  4006      outputBlockFormatter: outputBlockFormatter,
  4007      outputLogFormatter: outputLogFormatter,
  4008      outputPostFormatter: outputPostFormatter,
  4009      outputSyncingFormatter: outputSyncingFormatter
  4010  };
  4011  
  4012  
  4013  },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  4014  /*
  4015      This file is part of web3.js.
  4016  
  4017      web3.js is free software: you can redistribute it and/or modify
  4018      it under the terms of the GNU Lesser General Public License as published by
  4019      the Free Software Foundation, either version 3 of the License, or
  4020      (at your option) any later version.
  4021  
  4022      web3.js is distributed in the hope that it will be useful,
  4023      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4024      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4025      GNU Lesser General Public License for more details.
  4026  
  4027      You should have received a copy of the GNU Lesser General Public License
  4028      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4029  */
  4030  /**
  4031   * @file function.js
  4032   * @author Marek Kotewicz <marek@ethdev.com>
  4033   * @date 2015
  4034   */
  4035  
  4036  var coder = require('../solidity/coder');
  4037  var utils = require('../utils/utils');
  4038  var errors = require('./errors');
  4039  var formatters = require('./formatters');
  4040  var sha3 = require('../utils/sha3');
  4041  
  4042  /**
  4043   * This prototype should be used to call/sendTransaction to solidity functions
  4044   */
  4045  var SolidityFunction = function (eth, json, address) {
  4046      this._eth = eth;
  4047      this._inputTypes = json.inputs.map(function (i) {
  4048          return i.type;
  4049      });
  4050      this._outputTypes = json.outputs.map(function (i) {
  4051          return i.type;
  4052      });
  4053      this._constant = json.constant;
  4054      this._payable = json.payable;
  4055      this._name = utils.transformToFullName(json);
  4056      this._address = address;
  4057  };
  4058  
  4059  SolidityFunction.prototype.extractCallback = function (args) {
  4060      if (utils.isFunction(args[args.length - 1])) {
  4061          return args.pop(); // modify the args array!
  4062      }
  4063  };
  4064  
  4065  SolidityFunction.prototype.extractDefaultBlock = function (args) {
  4066      if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  4067          return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  4068      }
  4069  };
  4070  
  4071  /**
  4072   * Should be called to check if the number of arguments is correct
  4073   *
  4074   * @method validateArgs
  4075   * @param {Array} arguments
  4076   * @throws {Error} if it is not
  4077   */
  4078  SolidityFunction.prototype.validateArgs = function (args) {
  4079      var inputArgs = args.filter(function (a) {
  4080        // filter the options object but not arguments that are arrays
  4081        return !( (utils.isObject(a) === true) &&
  4082                  (utils.isArray(a) === false) &&
  4083                  (utils.isBigNumber(a) === false)
  4084                );
  4085      });
  4086      if (inputArgs.length !== this._inputTypes.length) {
  4087          throw errors.InvalidNumberOfSolidityArgs();
  4088      }
  4089  };
  4090  
  4091  /**
  4092   * Should be used to create payload from arguments
  4093   *
  4094   * @method toPayload
  4095   * @param {Array} solidity function params
  4096   * @param {Object} optional payload options
  4097   */
  4098  SolidityFunction.prototype.toPayload = function (args) {
  4099      var options = {};
  4100      if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  4101          options = args[args.length - 1];
  4102      }
  4103      this.validateArgs(args);
  4104      options.to = this._address;
  4105      options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  4106      return options;
  4107  };
  4108  
  4109  /**
  4110   * Should be used to get function signature
  4111   *
  4112   * @method signature
  4113   * @return {String} function signature
  4114   */
  4115  SolidityFunction.prototype.signature = function () {
  4116      return sha3(this._name).slice(0, 8);
  4117  };
  4118  
  4119  
  4120  SolidityFunction.prototype.unpackOutput = function (output) {
  4121      if (!output) {
  4122          return;
  4123      }
  4124  
  4125      output = output.length >= 2 ? output.slice(2) : output;
  4126      var result = coder.decodeParams(this._outputTypes, output);
  4127      return result.length === 1 ? result[0] : result;
  4128  };
  4129  
  4130  /**
  4131   * Calls a contract function.
  4132   *
  4133   * @method call
  4134   * @param {...Object} Contract function arguments
  4135   * @param {function} If the last argument is a function, the contract function
  4136   *   call will be asynchronous, and the callback will be passed the
  4137   *   error and result.
  4138   * @return {String} output bytes
  4139   */
  4140  SolidityFunction.prototype.call = function () {
  4141      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4142      var callback = this.extractCallback(args);
  4143      var defaultBlock = this.extractDefaultBlock(args);
  4144      var payload = this.toPayload(args);
  4145  
  4146  
  4147      if (!callback) {
  4148          var output = this._eth.call(payload, defaultBlock);
  4149          return this.unpackOutput(output);
  4150      }
  4151  
  4152      var self = this;
  4153      this._eth.call(payload, defaultBlock, function (error, output) {
  4154          if (error) return callback(error, null);
  4155  
  4156          var unpacked = null;
  4157          try {
  4158              unpacked = self.unpackOutput(output);
  4159          }
  4160          catch (e) {
  4161              error = e;
  4162          }
  4163  
  4164          callback(error, unpacked);
  4165      });
  4166  };
  4167  
  4168  /**
  4169   * Should be used to sendTransaction to solidity function
  4170   *
  4171   * @method sendTransaction
  4172   */
  4173  SolidityFunction.prototype.sendTransaction = function () {
  4174      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4175      var callback = this.extractCallback(args);
  4176      var payload = this.toPayload(args);
  4177  
  4178      if (payload.value > 0 && !this._payable) {
  4179          throw new Error('Cannot send value to non-payable function');
  4180      }
  4181  
  4182      if (!callback) {
  4183          return this._eth.sendTransaction(payload);
  4184      }
  4185  
  4186      this._eth.sendTransaction(payload, callback);
  4187  };
  4188  
  4189  /**
  4190   * Should be used to estimateGas of solidity function
  4191   *
  4192   * @method estimateGas
  4193   */
  4194  SolidityFunction.prototype.estimateGas = function () {
  4195      var args = Array.prototype.slice.call(arguments);
  4196      var callback = this.extractCallback(args);
  4197      var payload = this.toPayload(args);
  4198  
  4199      if (!callback) {
  4200          return this._eth.estimateGas(payload);
  4201      }
  4202  
  4203      this._eth.estimateGas(payload, callback);
  4204  };
  4205  
  4206  /**
  4207   * Return the encoded data of the call
  4208   *
  4209   * @method getData
  4210   * @return {String} the encoded data
  4211   */
  4212  SolidityFunction.prototype.getData = function () {
  4213      var args = Array.prototype.slice.call(arguments);
  4214      var payload = this.toPayload(args);
  4215  
  4216      return payload.data;
  4217  };
  4218  
  4219  /**
  4220   * Should be used to get function display name
  4221   *
  4222   * @method displayName
  4223   * @return {String} display name of the function
  4224   */
  4225  SolidityFunction.prototype.displayName = function () {
  4226      return utils.extractDisplayName(this._name);
  4227  };
  4228  
  4229  /**
  4230   * Should be used to get function type name
  4231   *
  4232   * @method typeName
  4233   * @return {String} type name of the function
  4234   */
  4235  SolidityFunction.prototype.typeName = function () {
  4236      return utils.extractTypeName(this._name);
  4237  };
  4238  
  4239  /**
  4240   * Should be called to get rpc requests from solidity function
  4241   *
  4242   * @method request
  4243   * @returns {Object}
  4244   */
  4245  SolidityFunction.prototype.request = function () {
  4246      var args = Array.prototype.slice.call(arguments);
  4247      var callback = this.extractCallback(args);
  4248      var payload = this.toPayload(args);
  4249      var format = this.unpackOutput.bind(this);
  4250  
  4251      return {
  4252          method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  4253          callback: callback,
  4254          params: [payload],
  4255          format: format
  4256      };
  4257  };
  4258  
  4259  /**
  4260   * Should be called to execute function
  4261   *
  4262   * @method execute
  4263   */
  4264  SolidityFunction.prototype.execute = function () {
  4265      var transaction = !this._constant;
  4266  
  4267      // send transaction
  4268      if (transaction) {
  4269          return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  4270      }
  4271  
  4272      // call
  4273      return this.call.apply(this, Array.prototype.slice.call(arguments));
  4274  };
  4275  
  4276  /**
  4277   * Should be called to attach function to contract
  4278   *
  4279   * @method attachToContract
  4280   * @param {Contract}
  4281   */
  4282  SolidityFunction.prototype.attachToContract = function (contract) {
  4283      var execute = this.execute.bind(this);
  4284      execute.request = this.request.bind(this);
  4285      execute.call = this.call.bind(this);
  4286      execute.sendTransaction = this.sendTransaction.bind(this);
  4287      execute.estimateGas = this.estimateGas.bind(this);
  4288      execute.getData = this.getData.bind(this);
  4289      var displayName = this.displayName();
  4290      if (!contract[displayName]) {
  4291          contract[displayName] = execute;
  4292      }
  4293      contract[displayName][this.typeName()] = execute; // circular!!!!
  4294  };
  4295  
  4296  module.exports = SolidityFunction;
  4297  
  4298  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./errors":26,"./formatters":30}],32:[function(require,module,exports){
  4299  /*
  4300      This file is part of web3.js.
  4301  
  4302      web3.js is free software: you can redistribute it and/or modify
  4303      it under the terms of the GNU Lesser General Public License as published by
  4304      the Free Software Foundation, either version 3 of the License, or
  4305      (at your option) any later version.
  4306  
  4307      web3.js is distributed in the hope that it will be useful,
  4308      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4309      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4310      GNU Lesser General Public License for more details.
  4311  
  4312      You should have received a copy of the GNU Lesser General Public License
  4313      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4314  */
  4315  /** @file httpprovider.js
  4316   * @authors:
  4317   *   Marek Kotewicz <marek@ethdev.com>
  4318   *   Marian Oancea <marian@ethdev.com>
  4319   *   Fabian Vogelsteller <fabian@ethdev.com>
  4320   * @date 2015
  4321   */
  4322  
  4323  var errors = require('./errors');
  4324  
  4325  // workaround to use httpprovider in different envs
  4326  
  4327  // browser
  4328  if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  4329    XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  4330  // node
  4331  } else {
  4332    XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4333  }
  4334  
  4335  var XHR2 = require('xhr2'); // jshint ignore: line
  4336  
  4337  /**
  4338   * HttpProvider should be used to send rpc calls over http
  4339   */
  4340  var HttpProvider = function (host, timeout, user, password) {
  4341    this.host = host || 'http://localhost:8545';
  4342    this.timeout = timeout || 0;
  4343    this.user = user;
  4344    this.password = password;
  4345  };
  4346  
  4347  /**
  4348   * Should be called to prepare new XMLHttpRequest
  4349   *
  4350   * @method prepareRequest
  4351   * @param {Boolean} true if request should be async
  4352   * @return {XMLHttpRequest} object
  4353   */
  4354  HttpProvider.prototype.prepareRequest = function (async) {
  4355    var request;
  4356  
  4357    if (async) {
  4358      request = new XHR2();
  4359      request.timeout = this.timeout;
  4360    } else {
  4361      request = new XMLHttpRequest();
  4362    }
  4363  
  4364    request.open('POST', this.host, async);
  4365    if (this.user && this.password) {
  4366      var auth = 'Basic ' + new Buffer(this.user + ':' + this.password).toString('base64');
  4367      request.setRequestHeader('Authorization', auth);
  4368    } request.setRequestHeader('Content-Type', 'application/json');
  4369    return request;
  4370  };
  4371  
  4372  /**
  4373   * Should be called to make sync request
  4374   *
  4375   * @method send
  4376   * @param {Object} payload
  4377   * @return {Object} result
  4378   */
  4379  HttpProvider.prototype.send = function (payload) {
  4380    var request = this.prepareRequest(false);
  4381  
  4382    try {
  4383      request.send(JSON.stringify(payload));
  4384    } catch (error) {
  4385      throw errors.InvalidConnection(this.host);
  4386    }
  4387  
  4388    var result = request.responseText;
  4389  
  4390    try {
  4391      result = JSON.parse(result);
  4392    } catch (e) {
  4393      throw errors.InvalidResponse(request.responseText);
  4394    }
  4395  
  4396    return result;
  4397  };
  4398  
  4399  /**
  4400   * Should be used to make async request
  4401   *
  4402   * @method sendAsync
  4403   * @param {Object} payload
  4404   * @param {Function} callback triggered on end with (err, result)
  4405   */
  4406  HttpProvider.prototype.sendAsync = function (payload, callback) {
  4407    var request = this.prepareRequest(true);
  4408  
  4409    request.onreadystatechange = function () {
  4410      if (request.readyState === 4 && request.timeout !== 1) {
  4411        var result = request.responseText;
  4412        var error = null;
  4413  
  4414        try {
  4415          result = JSON.parse(result);
  4416        } catch (e) {
  4417          error = errors.InvalidResponse(request.responseText);
  4418        }
  4419  
  4420        callback(error, result);
  4421      }
  4422    };
  4423  
  4424    request.ontimeout = function () {
  4425      callback(errors.ConnectionTimeout(this.timeout));
  4426    };
  4427  
  4428    try {
  4429      request.send(JSON.stringify(payload));
  4430    } catch (error) {
  4431      callback(errors.InvalidConnection(this.host));
  4432    }
  4433  };
  4434  
  4435  /**
  4436   * Synchronously tries to make Http request
  4437   *
  4438   * @method isConnected
  4439   * @return {Boolean} returns true if request haven't failed. Otherwise false
  4440   */
  4441  HttpProvider.prototype.isConnected = function () {
  4442    try {
  4443      this.send({
  4444        id: 9999999999,
  4445        jsonrpc: '2.0',
  4446        method: 'net_listening',
  4447        params: []
  4448      });
  4449      return true;
  4450    } catch (e) {
  4451      return false;
  4452    }
  4453  };
  4454  
  4455  module.exports = HttpProvider;
  4456  
  4457  },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
  4458  /*
  4459      This file is part of web3.js.
  4460  
  4461      web3.js is free software: you can redistribute it and/or modify
  4462      it under the terms of the GNU Lesser General Public License as published by
  4463      the Free Software Foundation, either version 3 of the License, or
  4464      (at your option) any later version.
  4465  
  4466      web3.js is distributed in the hope that it will be useful,
  4467      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4468      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4469      GNU Lesser General Public License for more details.
  4470  
  4471      You should have received a copy of the GNU Lesser General Public License
  4472      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4473  */
  4474  /** 
  4475   * @file iban.js
  4476   * @author Marek Kotewicz <marek@ethdev.com>
  4477   * @date 2015
  4478   */
  4479  
  4480  var BigNumber = require('bignumber.js');
  4481  
  4482  var padLeft = function (string, bytes) {
  4483      var result = string;
  4484      while (result.length < bytes * 2) {
  4485          result = '0' + result;
  4486      }
  4487      return result;
  4488  };
  4489  
  4490  /**
  4491   * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  4492   * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  4493   *
  4494   * @method iso13616Prepare
  4495   * @param {String} iban the IBAN
  4496   * @returns {String} the prepared IBAN
  4497   */
  4498  var iso13616Prepare = function (iban) {
  4499      var A = 'A'.charCodeAt(0);
  4500      var Z = 'Z'.charCodeAt(0);
  4501  
  4502      iban = iban.toUpperCase();
  4503      iban = iban.substr(4) + iban.substr(0,4);
  4504  
  4505      return iban.split('').map(function(n){
  4506          var code = n.charCodeAt(0);
  4507          if (code >= A && code <= Z){
  4508              // A = 10, B = 11, ... Z = 35
  4509              return code - A + 10;
  4510          } else {
  4511              return n;
  4512          }
  4513      }).join('');
  4514  };
  4515  
  4516  /**
  4517   * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  4518   *
  4519   * @method mod9710
  4520   * @param {String} iban
  4521   * @returns {Number}
  4522   */
  4523  var mod9710 = function (iban) {
  4524      var remainder = iban,
  4525          block;
  4526  
  4527      while (remainder.length > 2){
  4528          block = remainder.slice(0, 9);
  4529          remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  4530      }
  4531  
  4532      return parseInt(remainder, 10) % 97;
  4533  };
  4534  
  4535  /**
  4536   * This prototype should be used to create iban object from iban correct string
  4537   *
  4538   * @param {String} iban
  4539   */
  4540  var Iban = function (iban) {
  4541      this._iban = iban;
  4542  };
  4543  
  4544  /**
  4545   * This method should be used to create iban object from ethereum address
  4546   *
  4547   * @method fromAddress
  4548   * @param {String} address
  4549   * @return {Iban} the IBAN object
  4550   */
  4551  Iban.fromAddress = function (address) {
  4552      var asBn = new BigNumber(address, 16);
  4553      var base36 = asBn.toString(36);
  4554      var padded = padLeft(base36, 15);
  4555      return Iban.fromBban(padded.toUpperCase());
  4556  };
  4557  
  4558  /**
  4559   * Convert the passed BBAN to an IBAN for this country specification.
  4560   * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  4561   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  4562   *
  4563   * @method fromBban
  4564   * @param {String} bban the BBAN to convert to IBAN
  4565   * @returns {Iban} the IBAN object
  4566   */
  4567  Iban.fromBban = function (bban) {
  4568      var countryCode = 'XE';
  4569  
  4570      var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  4571      var checkDigit = ('0' + (98 - remainder)).slice(-2);
  4572  
  4573      return new Iban(countryCode + checkDigit + bban);
  4574  };
  4575  
  4576  /**
  4577   * Should be used to create IBAN object for given institution and identifier
  4578   *
  4579   * @method createIndirect
  4580   * @param {Object} options, required options are "institution" and "identifier"
  4581   * @return {Iban} the IBAN object
  4582   */
  4583  Iban.createIndirect = function (options) {
  4584      return Iban.fromBban('ETH' + options.institution + options.identifier);
  4585  };
  4586  
  4587  /**
  4588   * Thos method should be used to check if given string is valid iban object
  4589   *
  4590   * @method isValid
  4591   * @param {String} iban string
  4592   * @return {Boolean} true if it is valid IBAN
  4593   */
  4594  Iban.isValid = function (iban) {
  4595      var i = new Iban(iban);
  4596      return i.isValid();
  4597  };
  4598  
  4599  /**
  4600   * Should be called to check if iban is correct
  4601   *
  4602   * @method isValid
  4603   * @returns {Boolean} true if it is, otherwise false
  4604   */
  4605  Iban.prototype.isValid = function () {
  4606      return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  4607          mod9710(iso13616Prepare(this._iban)) === 1;
  4608  };
  4609  
  4610  /**
  4611   * Should be called to check if iban number is direct
  4612   *
  4613   * @method isDirect
  4614   * @returns {Boolean} true if it is, otherwise false
  4615   */
  4616  Iban.prototype.isDirect = function () {
  4617      return this._iban.length === 34 || this._iban.length === 35;
  4618  };
  4619  
  4620  /**
  4621   * Should be called to check if iban number if indirect
  4622   *
  4623   * @method isIndirect
  4624   * @returns {Boolean} true if it is, otherwise false
  4625   */
  4626  Iban.prototype.isIndirect = function () {
  4627      return this._iban.length === 20;
  4628  };
  4629  
  4630  /**
  4631   * Should be called to get iban checksum
  4632   * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  4633   *
  4634   * @method checksum
  4635   * @returns {String} checksum
  4636   */
  4637  Iban.prototype.checksum = function () {
  4638      return this._iban.substr(2, 2);
  4639  };
  4640  
  4641  /**
  4642   * Should be called to get institution identifier
  4643   * eg. XREG
  4644   *
  4645   * @method institution
  4646   * @returns {String} institution identifier
  4647   */
  4648  Iban.prototype.institution = function () {
  4649      return this.isIndirect() ? this._iban.substr(7, 4) : '';
  4650  };
  4651  
  4652  /**
  4653   * Should be called to get client identifier within institution
  4654   * eg. GAVOFYORK
  4655   *
  4656   * @method client
  4657   * @returns {String} client identifier
  4658   */
  4659  Iban.prototype.client = function () {
  4660      return this.isIndirect() ? this._iban.substr(11) : '';
  4661  };
  4662  
  4663  /**
  4664   * Should be called to get client direct address
  4665   *
  4666   * @method address
  4667   * @returns {String} client direct address
  4668   */
  4669  Iban.prototype.address = function () {
  4670      if (this.isDirect()) {
  4671          var base36 = this._iban.substr(4);
  4672          var asBn = new BigNumber(base36, 36);
  4673          return padLeft(asBn.toString(16), 20);
  4674      } 
  4675  
  4676      return '';
  4677  };
  4678  
  4679  Iban.prototype.toString = function () {
  4680      return this._iban;
  4681  };
  4682  
  4683  module.exports = Iban;
  4684  
  4685  
  4686  },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  4687  /*
  4688      This file is part of web3.js.
  4689  
  4690      web3.js is free software: you can redistribute it and/or modify
  4691      it under the terms of the GNU Lesser General Public License as published by
  4692      the Free Software Foundation, either version 3 of the License, or
  4693      (at your option) any later version.
  4694  
  4695      web3.js is distributed in the hope that it will be useful,
  4696      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4697      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4698      GNU Lesser General Public License for more details.
  4699  
  4700      You should have received a copy of the GNU Lesser General Public License
  4701      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4702  */
  4703  /** @file ipcprovider.js
  4704   * @authors:
  4705   *   Fabian Vogelsteller <fabian@ethdev.com>
  4706   * @date 2015
  4707   */
  4708  
  4709  "use strict";
  4710  
  4711  var utils = require('../utils/utils');
  4712  var errors = require('./errors');
  4713  
  4714  
  4715  var IpcProvider = function (path, net) {
  4716      var _this = this;
  4717      this.responseCallbacks = {};
  4718      this.path = path;
  4719      
  4720      this.connection = net.connect({path: this.path});
  4721  
  4722      this.connection.on('error', function(e){
  4723          console.error('IPC Connection Error', e);
  4724          _this._timeout();
  4725      });
  4726  
  4727      this.connection.on('end', function(){
  4728          _this._timeout();
  4729      }); 
  4730  
  4731  
  4732      // LISTEN FOR CONNECTION RESPONSES
  4733      this.connection.on('data', function(data) {
  4734          /*jshint maxcomplexity: 6 */
  4735  
  4736          _this._parseResponse(data.toString()).forEach(function(result){
  4737  
  4738              var id = null;
  4739  
  4740              // get the id which matches the returned id
  4741              if(utils.isArray(result)) {
  4742                  result.forEach(function(load){
  4743                      if(_this.responseCallbacks[load.id])
  4744                          id = load.id;
  4745                  });
  4746              } else {
  4747                  id = result.id;
  4748              }
  4749  
  4750              // fire the callback
  4751              if(_this.responseCallbacks[id]) {
  4752                  _this.responseCallbacks[id](null, result);
  4753                  delete _this.responseCallbacks[id];
  4754              }
  4755          });
  4756      });
  4757  };
  4758  
  4759  /**
  4760  Will parse the response and make an array out of it.
  4761  
  4762  @method _parseResponse
  4763  @param {String} data
  4764  */
  4765  IpcProvider.prototype._parseResponse = function(data) {
  4766      var _this = this,
  4767          returnValues = [];
  4768      
  4769      // DE-CHUNKER
  4770      var dechunkedData = data
  4771          .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4772          .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4773          .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4774          .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4775          .split('|--|');
  4776  
  4777      dechunkedData.forEach(function(data){
  4778  
  4779          // prepend the last chunk
  4780          if(_this.lastChunk)
  4781              data = _this.lastChunk + data;
  4782  
  4783          var result = null;
  4784  
  4785          try {
  4786              result = JSON.parse(data);
  4787  
  4788          } catch(e) {
  4789  
  4790              _this.lastChunk = data;
  4791  
  4792              // start timeout to cancel all requests
  4793              clearTimeout(_this.lastChunkTimeout);
  4794              _this.lastChunkTimeout = setTimeout(function(){
  4795                  _this._timeout();
  4796                  throw errors.InvalidResponse(data);
  4797              }, 1000 * 15);
  4798  
  4799              return;
  4800          }
  4801  
  4802          // cancel timeout and set chunk to null
  4803          clearTimeout(_this.lastChunkTimeout);
  4804          _this.lastChunk = null;
  4805  
  4806          if(result)
  4807              returnValues.push(result);
  4808      });
  4809  
  4810      return returnValues;
  4811  };
  4812  
  4813  
  4814  /**
  4815  Get the adds a callback to the responseCallbacks object,
  4816  which will be called if a response matching the response Id will arrive.
  4817  
  4818  @method _addResponseCallback
  4819  */
  4820  IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4821      var id = payload.id || payload[0].id;
  4822      var method = payload.method || payload[0].method;
  4823  
  4824      this.responseCallbacks[id] = callback;
  4825      this.responseCallbacks[id].method = method;
  4826  };
  4827  
  4828  /**
  4829  Timeout all requests when the end/error event is fired
  4830  
  4831  @method _timeout
  4832  */
  4833  IpcProvider.prototype._timeout = function() {
  4834      for(var key in this.responseCallbacks) {
  4835          if(this.responseCallbacks.hasOwnProperty(key)){
  4836              this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4837              delete this.responseCallbacks[key];
  4838          }
  4839      }
  4840  };
  4841  
  4842  
  4843  /**
  4844  Check if the current connection is still valid.
  4845  
  4846  @method isConnected
  4847  */
  4848  IpcProvider.prototype.isConnected = function() {
  4849      var _this = this;
  4850  
  4851      // try reconnect, when connection is gone
  4852      if(!_this.connection.writable)
  4853          _this.connection.connect({path: _this.path});
  4854  
  4855      return !!this.connection.writable;
  4856  };
  4857  
  4858  IpcProvider.prototype.send = function (payload) {
  4859  
  4860      if(this.connection.writeSync) {
  4861          var result;
  4862  
  4863          // try reconnect, when connection is gone
  4864          if(!this.connection.writable)
  4865              this.connection.connect({path: this.path});
  4866  
  4867          var data = this.connection.writeSync(JSON.stringify(payload));
  4868  
  4869          try {
  4870              result = JSON.parse(data);
  4871          } catch(e) {
  4872              throw errors.InvalidResponse(data);                
  4873          }
  4874  
  4875          return result;
  4876  
  4877      } else {
  4878          throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4879      }
  4880  };
  4881  
  4882  IpcProvider.prototype.sendAsync = function (payload, callback) {
  4883      // try reconnect, when connection is gone
  4884      if(!this.connection.writable)
  4885          this.connection.connect({path: this.path});
  4886  
  4887  
  4888      this.connection.write(JSON.stringify(payload));
  4889      this._addResponseCallback(payload, callback);
  4890  };
  4891  
  4892  module.exports = IpcProvider;
  4893  
  4894  
  4895  },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4896  /*
  4897      This file is part of web3.js.
  4898  
  4899      web3.js is free software: you can redistribute it and/or modify
  4900      it under the terms of the GNU Lesser General Public License as published by
  4901      the Free Software Foundation, either version 3 of the License, or
  4902      (at your option) any later version.
  4903  
  4904      web3.js is distributed in the hope that it will be useful,
  4905      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4906      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4907      GNU Lesser General Public License for more details.
  4908  
  4909      You should have received a copy of the GNU Lesser General Public License
  4910      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4911  */
  4912  /** @file jsonrpc.js
  4913   * @authors:
  4914   *   Marek Kotewicz <marek@ethdev.com>
  4915   *   Aaron Kumavis <aaron@kumavis.me>
  4916   * @date 2015
  4917   */
  4918  
  4919  // Initialize Jsonrpc as a simple object with utility functions.
  4920  var Jsonrpc = {
  4921      messageId: 0
  4922  };
  4923  
  4924  /**
  4925   * Should be called to valid json create payload object
  4926   *
  4927   * @method toPayload
  4928   * @param {Function} method of jsonrpc call, required
  4929   * @param {Array} params, an array of method params, optional
  4930   * @returns {Object} valid jsonrpc payload object
  4931   */
  4932  Jsonrpc.toPayload = function (method, params) {
  4933      if (!method)
  4934          console.error('jsonrpc method should be specified!');
  4935  
  4936      // advance message ID
  4937      Jsonrpc.messageId++;
  4938  
  4939      return {
  4940          jsonrpc: '2.0',
  4941          id: Jsonrpc.messageId,
  4942          method: method,
  4943          params: params || []
  4944      };
  4945  };
  4946  
  4947  /**
  4948   * Should be called to check if jsonrpc response is valid
  4949   *
  4950   * @method isValidResponse
  4951   * @param {Object}
  4952   * @returns {Boolean} true if response is valid, otherwise false
  4953   */
  4954  Jsonrpc.isValidResponse = function (response) {
  4955      return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
  4956  
  4957      function validateSingleMessage(message){
  4958        return !!message &&
  4959          !message.error &&
  4960          message.jsonrpc === '2.0' &&
  4961          typeof message.id === 'number' &&
  4962          message.result !== undefined; // only undefined is not valid json object
  4963      }
  4964  };
  4965  
  4966  /**
  4967   * Should be called to create batch payload object
  4968   *
  4969   * @method toBatchPayload
  4970   * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4971   * @returns {Array} batch payload
  4972   */
  4973  Jsonrpc.toBatchPayload = function (messages) {
  4974      return messages.map(function (message) {
  4975          return Jsonrpc.toPayload(message.method, message.params);
  4976      });
  4977  };
  4978  
  4979  module.exports = Jsonrpc;
  4980  
  4981  
  4982  },{}],36:[function(require,module,exports){
  4983  /*
  4984      This file is part of web3.js.
  4985  
  4986      web3.js is free software: you can redistribute it and/or modify
  4987      it under the terms of the GNU Lesser General Public License as published by
  4988      the Free Software Foundation, either version 3 of the License, or
  4989      (at your option) any later version.
  4990  
  4991      web3.js is distributed in the hope that it will be useful,
  4992      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4993      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4994      GNU Lesser General Public License for more details.
  4995  
  4996      You should have received a copy of the GNU Lesser General Public License
  4997      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4998  */
  4999  /**
  5000   * @file method.js
  5001   * @author Marek Kotewicz <marek@ethdev.com>
  5002   * @date 2015
  5003   */
  5004  
  5005  var utils = require('../utils/utils');
  5006  var errors = require('./errors');
  5007  
  5008  var Method = function (options) {
  5009      this.name = options.name;
  5010      this.call = options.call;
  5011      this.params = options.params || 0;
  5012      this.inputFormatter = options.inputFormatter;
  5013      this.outputFormatter = options.outputFormatter;
  5014      this.requestManager = null;
  5015  };
  5016  
  5017  Method.prototype.setRequestManager = function (rm) {
  5018      this.requestManager = rm;
  5019  };
  5020  
  5021  /**
  5022   * Should be used to determine name of the jsonrpc method based on arguments
  5023   *
  5024   * @method getCall
  5025   * @param {Array} arguments
  5026   * @return {String} name of jsonrpc method
  5027   */
  5028  Method.prototype.getCall = function (args) {
  5029      return utils.isFunction(this.call) ? this.call(args) : this.call;
  5030  };
  5031  
  5032  /**
  5033   * Should be used to extract callback from array of arguments. Modifies input param
  5034   *
  5035   * @method extractCallback
  5036   * @param {Array} arguments
  5037   * @return {Function|Null} callback, if exists
  5038   */
  5039  Method.prototype.extractCallback = function (args) {
  5040      if (utils.isFunction(args[args.length - 1])) {
  5041          return args.pop(); // modify the args array!
  5042      }
  5043  };
  5044  
  5045  /**
  5046   * Should be called to check if the number of arguments is correct
  5047   * 
  5048   * @method validateArgs
  5049   * @param {Array} arguments
  5050   * @throws {Error} if it is not
  5051   */
  5052  Method.prototype.validateArgs = function (args) {
  5053      if (args.length !== this.params) {
  5054          throw errors.InvalidNumberOfRPCParams();
  5055      }
  5056  };
  5057  
  5058  /**
  5059   * Should be called to format input args of method
  5060   * 
  5061   * @method formatInput
  5062   * @param {Array}
  5063   * @return {Array}
  5064   */
  5065  Method.prototype.formatInput = function (args) {
  5066      if (!this.inputFormatter) {
  5067          return args;
  5068      }
  5069  
  5070      return this.inputFormatter.map(function (formatter, index) {
  5071          return formatter ? formatter(args[index]) : args[index];
  5072      });
  5073  };
  5074  
  5075  /**
  5076   * Should be called to format output(result) of method
  5077   *
  5078   * @method formatOutput
  5079   * @param {Object}
  5080   * @return {Object}
  5081   */
  5082  Method.prototype.formatOutput = function (result) {
  5083      return this.outputFormatter && result ? this.outputFormatter(result) : result;
  5084  };
  5085  
  5086  /**
  5087   * Should create payload from given input args
  5088   *
  5089   * @method toPayload
  5090   * @param {Array} args
  5091   * @return {Object}
  5092   */
  5093  Method.prototype.toPayload = function (args) {
  5094      var call = this.getCall(args);
  5095      var callback = this.extractCallback(args);
  5096      var params = this.formatInput(args);
  5097      this.validateArgs(params);
  5098  
  5099      return {
  5100          method: call,
  5101          params: params,
  5102          callback: callback
  5103      };
  5104  };
  5105  
  5106  Method.prototype.attachToObject = function (obj) {
  5107      var func = this.buildCall();
  5108      func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  5109      var name = this.name.split('.');
  5110      if (name.length > 1) {
  5111          obj[name[0]] = obj[name[0]] || {};
  5112          obj[name[0]][name[1]] = func;
  5113      } else {
  5114          obj[name[0]] = func; 
  5115      }
  5116  };
  5117  
  5118  Method.prototype.buildCall = function() {
  5119      var method = this;
  5120      var send = function () {
  5121          var payload = method.toPayload(Array.prototype.slice.call(arguments));
  5122          if (payload.callback) {
  5123              return method.requestManager.sendAsync(payload, function (err, result) {
  5124                  payload.callback(err, method.formatOutput(result));
  5125              });
  5126          }
  5127          return method.formatOutput(method.requestManager.send(payload));
  5128      };
  5129      send.request = this.request.bind(this);
  5130      return send;
  5131  };
  5132  
  5133  /**
  5134   * Should be called to create pure JSONRPC request which can be used in batch request
  5135   *
  5136   * @method request
  5137   * @param {...} params
  5138   * @return {Object} jsonrpc request
  5139   */
  5140  Method.prototype.request = function () {
  5141      var payload = this.toPayload(Array.prototype.slice.call(arguments));
  5142      payload.format = this.formatOutput.bind(this);
  5143      return payload;
  5144  };
  5145  
  5146  module.exports = Method;
  5147  
  5148  },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  5149  /*
  5150      This file is part of web3.js.
  5151  
  5152      web3.js is free software: you can redistribute it and/or modify
  5153      it under the terms of the GNU Lesser General Public License as published by
  5154      the Free Software Foundation, either version 3 of the License, or
  5155      (at your option) any later version.
  5156  
  5157      web3.js is distributed in the hope that it will be useful,
  5158      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5159      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5160      GNU Lesser General Public License for more details.
  5161  
  5162      You should have received a copy of the GNU Lesser General Public License
  5163      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5164  */
  5165  /** @file db.js
  5166   * @authors:
  5167   *   Marek Kotewicz <marek@ethdev.com>
  5168   * @date 2015
  5169   */
  5170  
  5171  var Method = require('../method');
  5172  
  5173  var DB = function (web3) {
  5174      this._requestManager = web3._requestManager;
  5175  
  5176      var self = this;
  5177      
  5178      methods().forEach(function(method) { 
  5179          method.attachToObject(self);
  5180          method.setRequestManager(web3._requestManager);
  5181      });
  5182  };
  5183  
  5184  var methods = function () {
  5185      var putString = new Method({
  5186          name: 'putString',
  5187          call: 'db_putString',
  5188          params: 3
  5189      });
  5190  
  5191      var getString = new Method({
  5192          name: 'getString',
  5193          call: 'db_getString',
  5194          params: 2
  5195      });
  5196  
  5197      var putHex = new Method({
  5198          name: 'putHex',
  5199          call: 'db_putHex',
  5200          params: 3
  5201      });
  5202  
  5203      var getHex = new Method({
  5204          name: 'getHex',
  5205          call: 'db_getHex',
  5206          params: 2
  5207      });
  5208  
  5209      return [
  5210          putString, getString, putHex, getHex
  5211      ];
  5212  };
  5213  
  5214  module.exports = DB;
  5215  
  5216  },{"../method":36}],38:[function(require,module,exports){
  5217  /*
  5218      This file is part of web3.js.
  5219  
  5220      web3.js is free software: you can redistribute it and/or modify
  5221      it under the terms of the GNU Lesser General Public License as published by
  5222      the Free Software Foundation, either version 3 of the License, or
  5223      (at your option) any later version.
  5224  
  5225      web3.js is distributed in the hope that it will be useful,
  5226      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5227      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5228      GNU Lesser General Public License for more details.
  5229  
  5230      You should have received a copy of the GNU Lesser General Public License
  5231      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5232  */
  5233  /**
  5234   * @file neatptc.js
  5235   * @author Marek Kotewicz <marek@ethdev.com>
  5236   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5237   * @date 2015
  5238   */
  5239  
  5240  "use strict";
  5241  
  5242  var formatters = require('../formatters');
  5243  var utils = require('../../utils/utils');
  5244  var Method = require('../method');
  5245  var Property = require('../property');
  5246  var c = require('../../utils/config');
  5247  var Contract = require('../contract');
  5248  var watches = require('./watches');
  5249  var Filter = require('../filter');
  5250  var IsSyncing = require('../syncing');
  5251  var namereg = require('../namereg');
  5252  var Iban = require('../iban');
  5253  var transfer = require('../transfer');
  5254  
  5255  var blockCall = function (args) {
  5256      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  5257  };
  5258  
  5259  var transactionFromBlockCall = function (args) {
  5260      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  5261  };
  5262  
  5263  var uncleCall = function (args) {
  5264      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  5265  };
  5266  
  5267  var getBlockTransactionCountCall = function (args) {
  5268      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  5269  };
  5270  
  5271  var uncleCountCall = function (args) {
  5272      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  5273  };
  5274  
  5275  function Eth(web3) {
  5276      this._requestManager = web3._requestManager;
  5277  
  5278      var self = this;
  5279  
  5280      methods().forEach(function(method) {
  5281          method.attachToObject(self);
  5282          method.setRequestManager(self._requestManager);
  5283      });
  5284  
  5285      properties().forEach(function(p) {
  5286          p.attachToObject(self);
  5287          p.setRequestManager(self._requestManager);
  5288      });
  5289  
  5290  
  5291      this.iban = Iban;
  5292      this.sendIBANTransaction = transfer.bind(null, this);
  5293  }
  5294  
  5295  Object.defineProperty(Eth.prototype, 'defaultBlock', {
  5296      get: function () {
  5297          return c.defaultBlock;
  5298      },
  5299      set: function (val) {
  5300          c.defaultBlock = val;
  5301          return val;
  5302      }
  5303  });
  5304  
  5305  Object.defineProperty(Eth.prototype, 'defaultAccount', {
  5306      get: function () {
  5307          return c.defaultAccount;
  5308      },
  5309      set: function (val) {
  5310          c.defaultAccount = val;
  5311          return val;
  5312      }
  5313  });
  5314  
  5315  var methods = function () {
  5316      var getBalance = new Method({
  5317          name: 'getBalance',
  5318          call: 'eth_getBalance',
  5319          params: 2,
  5320          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  5321          outputFormatter: formatters.outputBigNumberFormatter
  5322      });
  5323  
  5324      var getStorageAt = new Method({
  5325          name: 'getStorageAt',
  5326          call: 'eth_getStorageAt',
  5327          params: 3,
  5328          inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  5329      });
  5330  
  5331      var getCode = new Method({
  5332          name: 'getCode',
  5333          call: 'eth_getCode',
  5334          params: 2,
  5335          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  5336      });
  5337  
  5338      var getBlock = new Method({
  5339          name: 'getBlock',
  5340          call: blockCall,
  5341          params: 2,
  5342          inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  5343          outputFormatter: formatters.outputBlockFormatter
  5344      });
  5345  
  5346      var getUncle = new Method({
  5347          name: 'getUncle',
  5348          call: uncleCall,
  5349          params: 2,
  5350          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5351          outputFormatter: formatters.outputBlockFormatter,
  5352  
  5353      });
  5354  
  5355      var getCompilers = new Method({
  5356          name: 'getCompilers',
  5357          call: 'eth_getCompilers',
  5358          params: 0
  5359      });
  5360  
  5361      var getBlockTransactionCount = new Method({
  5362          name: 'getBlockTransactionCount',
  5363          call: getBlockTransactionCountCall,
  5364          params: 1,
  5365          inputFormatter: [formatters.inputBlockNumberFormatter],
  5366          outputFormatter: utils.toDecimal
  5367      });
  5368  
  5369      var getBlockUncleCount = new Method({
  5370          name: 'getBlockUncleCount',
  5371          call: uncleCountCall,
  5372          params: 1,
  5373          inputFormatter: [formatters.inputBlockNumberFormatter],
  5374          outputFormatter: utils.toDecimal
  5375      });
  5376  
  5377      var getTransaction = new Method({
  5378          name: 'getTransaction',
  5379          call: 'eth_getTransactionByHash',
  5380          params: 1,
  5381          outputFormatter: formatters.outputTransactionFormatter
  5382      });
  5383  
  5384      var getTransactionFromBlock = new Method({
  5385          name: 'getTransactionFromBlock',
  5386          call: transactionFromBlockCall,
  5387          params: 2,
  5388          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5389          outputFormatter: formatters.outputTransactionFormatter
  5390      });
  5391  
  5392      var getTransactionReceipt = new Method({
  5393          name: 'getTransactionReceipt',
  5394          call: 'eth_getTransactionReceipt',
  5395          params: 1,
  5396          outputFormatter: formatters.outputTransactionReceiptFormatter
  5397      });
  5398  
  5399      var getTransactionCount = new Method({
  5400          name: 'getTransactionCount',
  5401          call: 'eth_getTransactionCount',
  5402          params: 2,
  5403          inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  5404          outputFormatter: utils.toDecimal
  5405      });
  5406  
  5407      var sendRawTransaction = new Method({
  5408          name: 'sendRawTransaction',
  5409          call: 'eth_sendRawTransaction',
  5410          params: 1,
  5411          inputFormatter: [null]
  5412      });
  5413  
  5414      var sendTransaction = new Method({
  5415          name: 'sendTransaction',
  5416          call: 'eth_sendTransaction',
  5417          params: 1,
  5418          inputFormatter: [formatters.inputTransactionFormatter]
  5419      });
  5420  
  5421      var signTransaction = new Method({
  5422          name: 'signTransaction',
  5423          call: 'eth_signTransaction',
  5424          params: 1,
  5425          inputFormatter: [formatters.inputTransactionFormatter]
  5426      });
  5427  
  5428      var sign = new Method({
  5429          name: 'sign',
  5430          call: 'eth_sign',
  5431          params: 2,
  5432          inputFormatter: [formatters.inputAddressFormatter, null]
  5433      });
  5434  
  5435      var call = new Method({
  5436          name: 'call',
  5437          call: 'eth_call',
  5438          params: 2,
  5439          inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  5440      });
  5441  
  5442      var estimateGas = new Method({
  5443          name: 'estimateGas',
  5444          call: 'eth_estimateGas',
  5445          params: 1,
  5446          inputFormatter: [formatters.inputCallFormatter],
  5447          outputFormatter: utils.toDecimal
  5448      });
  5449  
  5450      var compileSolidity = new Method({
  5451          name: 'compile.solidity',
  5452          call: 'eth_compileSolidity',
  5453          params: 1
  5454      });
  5455  
  5456      var compileLLL = new Method({
  5457          name: 'compile.lll',
  5458          call: 'eth_compileLLL',
  5459          params: 1
  5460      });
  5461  
  5462      var compileSerpent = new Method({
  5463          name: 'compile.serpent',
  5464          call: 'eth_compileSerpent',
  5465          params: 1
  5466      });
  5467  
  5468      var submitWork = new Method({
  5469          name: 'submitWork',
  5470          call: 'eth_submitWork',
  5471          params: 3
  5472      });
  5473  
  5474      var getWork = new Method({
  5475          name: 'getWork',
  5476          call: 'eth_getWork',
  5477          params: 0
  5478      });
  5479  
  5480      return [
  5481          getBalance,
  5482          getStorageAt,
  5483          getCode,
  5484          getBlock,
  5485          getUncle,
  5486          getCompilers,
  5487          getBlockTransactionCount,
  5488          getBlockUncleCount,
  5489          getTransaction,
  5490          getTransactionFromBlock,
  5491          getTransactionReceipt,
  5492          getTransactionCount,
  5493          call,
  5494          estimateGas,
  5495          sendRawTransaction,
  5496          signTransaction,
  5497          sendTransaction,
  5498          sign,
  5499          compileSolidity,
  5500          compileLLL,
  5501          compileSerpent,
  5502          submitWork,
  5503          getWork
  5504      ];
  5505  };
  5506  
  5507  
  5508  var properties = function () {
  5509      return [
  5510          new Property({
  5511              name: 'coinbase',
  5512              getter: 'eth_coinbase'
  5513          }),
  5514          new Property({
  5515              name: 'mining',
  5516              getter: 'eth_mining'
  5517          }),
  5518          new Property({
  5519              name: 'hashrate',
  5520              getter: 'eth_hashrate',
  5521              outputFormatter: utils.toDecimal
  5522          }),
  5523          new Property({
  5524              name: 'syncing',
  5525              getter: 'eth_syncing',
  5526              outputFormatter: formatters.outputSyncingFormatter
  5527          }),
  5528          new Property({
  5529              name: 'gasPrice',
  5530              getter: 'eth_gasPrice',
  5531              outputFormatter: formatters.outputBigNumberFormatter
  5532          }),
  5533          new Property({
  5534              name: 'accounts',
  5535              getter: 'eth_accounts'
  5536          }),
  5537          new Property({
  5538              name: 'blockNumber',
  5539              getter: 'eth_blockNumber',
  5540              outputFormatter: utils.toDecimal
  5541          }),
  5542          new Property({
  5543              name: 'protocolVersion',
  5544              getter: 'eth_protocolVersion'
  5545          })
  5546      ];
  5547  };
  5548  
  5549  Eth.prototype.contract = function (abi) {
  5550      var factory = new Contract(this, abi);
  5551      return factory;
  5552  };
  5553  
  5554  Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
  5555      return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
  5556  };
  5557  
  5558  Eth.prototype.namereg = function () {
  5559      return this.contract(namereg.global.abi).at(namereg.global.address);
  5560  };
  5561  
  5562  Eth.prototype.icapNamereg = function () {
  5563      return this.contract(namereg.icap.abi).at(namereg.icap.address);
  5564  };
  5565  
  5566  Eth.prototype.isSyncing = function (callback) {
  5567      return new IsSyncing(this._requestManager, callback);
  5568  };
  5569  
  5570  module.exports = Eth;
  5571  
  5572  },{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(require,module,exports){
  5573  /*
  5574      This file is part of web3.js.
  5575  
  5576      web3.js is free software: you can redistribute it and/or modify
  5577      it under the terms of the GNU Lesser General Public License as published by
  5578      the Free Software Foundation, either version 3 of the License, or
  5579      (at your option) any later version.
  5580  
  5581      web3.js is distributed in the hope that it will be useful,
  5582      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5583      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5584      GNU Lesser General Public License for more details.
  5585  
  5586      You should have received a copy of the GNU Lesser General Public License
  5587      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5588  */
  5589  /** @file neatptc.js
  5590   * @authors:
  5591   *   Marek Kotewicz <marek@ethdev.com>
  5592   * @date 2015
  5593   */
  5594  
  5595  var utils = require('../../utils/utils');
  5596  var Property = require('../property');
  5597  
  5598  var Net = function (web3) {
  5599      this._requestManager = web3._requestManager;
  5600  
  5601      var self = this;
  5602  
  5603      properties().forEach(function(p) { 
  5604          p.attachToObject(self);
  5605          p.setRequestManager(web3._requestManager);
  5606      });
  5607  };
  5608  
  5609  /// @returns an array of objects describing web3.neatptc api properties
  5610  var properties = function () {
  5611      return [
  5612          new Property({
  5613              name: 'listening',
  5614              getter: 'net_listening'
  5615          }),
  5616          new Property({
  5617              name: 'peerCount',
  5618              getter: 'net_peerCount',
  5619              outputFormatter: utils.toDecimal
  5620          })
  5621      ];
  5622  };
  5623  
  5624  module.exports = Net;
  5625  
  5626  },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
  5627  /*
  5628      This file is part of web3.js.
  5629  
  5630      web3.js is free software: you can redistribute it and/or modify
  5631      it under the terms of the GNU Lesser General Public License as published by
  5632      the Free Software Foundation, either version 3 of the License, or
  5633      (at your option) any later version.
  5634  
  5635      web3.js is distributed in the hope that it will be useful,
  5636      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5637      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5638      GNU Lesser General Public License for more details.
  5639  
  5640      You should have received a copy of the GNU Lesser General Public License
  5641      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5642  */
  5643  /**
  5644   * @file neatptc.js
  5645   * @author Marek Kotewicz <marek@ethdev.com>
  5646   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5647   * @date 2015
  5648   */
  5649  
  5650  "use strict";
  5651  
  5652  var Method = require('../method');
  5653  var Property = require('../property');
  5654  var formatters = require('../formatters');
  5655  
  5656  function Personal(web3) {
  5657      this._requestManager = web3._requestManager;
  5658  
  5659      var self = this;
  5660  
  5661      methods().forEach(function(method) {
  5662          method.attachToObject(self);
  5663          method.setRequestManager(self._requestManager);
  5664      });
  5665  
  5666      properties().forEach(function(p) {
  5667          p.attachToObject(self);
  5668          p.setRequestManager(self._requestManager);
  5669      });
  5670  }
  5671  
  5672  var methods = function () {
  5673      var newAccount = new Method({
  5674          name: 'newAccount',
  5675          call: 'personal_newAccount',
  5676          params: 1,
  5677          inputFormatter: [null]
  5678      });
  5679  
  5680      var importRawKey = new Method({
  5681          name: 'importRawKey',
  5682  		call: 'personal_importRawKey',
  5683  		params: 2
  5684      });
  5685  
  5686      var sign = new Method({
  5687          name: 'sign',
  5688  		call: 'personal_sign',
  5689  		params: 3,
  5690  		inputFormatter: [null, formatters.inputAddressFormatter, null]
  5691      });
  5692  
  5693      var ecRecover = new Method({
  5694          name: 'ecRecover',
  5695  		call: 'personal_ecRecover',
  5696  		params: 2
  5697      });
  5698  
  5699      var unlockAccount = new Method({
  5700          name: 'unlockAccount',
  5701          call: 'personal_unlockAccount',
  5702          params: 3,
  5703          inputFormatter: [formatters.inputAddressFormatter, null, null]
  5704      });
  5705  
  5706      var sendTransaction = new Method({
  5707          name: 'sendTransaction',
  5708          call: 'personal_sendTransaction',
  5709          params: 2,
  5710          inputFormatter: [formatters.inputTransactionFormatter, null]
  5711      });
  5712  
  5713      var lockAccount = new Method({
  5714          name: 'lockAccount',
  5715          call: 'personal_lockAccount',
  5716          params: 1,
  5717          inputFormatter: [formatters.inputAddressFormatter]
  5718      });
  5719  
  5720      return [
  5721          newAccount,
  5722          importRawKey,
  5723          unlockAccount,
  5724          ecRecover,
  5725          sign,
  5726          sendTransaction,
  5727          lockAccount
  5728      ];
  5729  };
  5730  
  5731  var properties = function () {
  5732      return [
  5733          new Property({
  5734              name: 'listAccounts',
  5735              getter: 'personal_listAccounts'
  5736          })
  5737      ];
  5738  };
  5739  
  5740  
  5741  module.exports = Personal;
  5742  
  5743  },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
  5744  /*
  5745      This file is part of web3.js.
  5746  
  5747      web3.js is free software: you can redistribute it and/or modify
  5748      it under the terms of the GNU Lesser General Public License as published by
  5749      the Free Software Foundation, either version 3 of the License, or
  5750      (at your option) any later version.
  5751  
  5752      web3.js is distributed in the hope that it will be useful,
  5753      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5754      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5755      GNU Lesser General Public License for more details.
  5756  
  5757      You should have received a copy of the GNU Lesser General Public License
  5758      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5759  */
  5760  /** @file shh.js
  5761   * @authors:
  5762   *   Fabian Vogelsteller <fabian@neatchain.org>
  5763   *   Marek Kotewicz <marek@ethcore.io>
  5764   * @date 2017
  5765   */
  5766  
  5767  var Method = require('../method');
  5768  var Filter = require('../filter');
  5769  var watches = require('./watches');
  5770  
  5771  var Shh = function (web3) {
  5772      this._requestManager = web3._requestManager;
  5773  
  5774      var self = this;
  5775  
  5776      methods().forEach(function(method) {
  5777          method.attachToObject(self);
  5778          method.setRequestManager(self._requestManager);
  5779      });
  5780  };
  5781  
  5782  Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
  5783      return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
  5784  };
  5785  
  5786  var methods = function () {
  5787  
  5788      return [
  5789          new Method({
  5790              name: 'version',
  5791              call: 'shh_version',
  5792              params: 0
  5793          }),
  5794          new Method({
  5795              name: 'info',
  5796              call: 'shh_info',
  5797              params: 0
  5798          }),
  5799          new Method({
  5800              name: 'setMaxMessageSize',
  5801              call: 'shh_setMaxMessageSize',
  5802              params: 1
  5803          }),
  5804          new Method({
  5805              name: 'setMinPoW',
  5806              call: 'shh_setMinPoW',
  5807              params: 1
  5808          }),
  5809          new Method({
  5810              name: 'markTrustedPeer',
  5811              call: 'shh_markTrustedPeer',
  5812              params: 1
  5813          }),
  5814          new Method({
  5815              name: 'newKeyPair',
  5816              call: 'shh_newKeyPair',
  5817              params: 0
  5818          }),
  5819          new Method({
  5820              name: 'addPrivateKey',
  5821              call: 'shh_addPrivateKey',
  5822              params: 1
  5823          }),
  5824          new Method({
  5825              name: 'deleteKeyPair',
  5826              call: 'shh_deleteKeyPair',
  5827              params: 1
  5828          }),
  5829          new Method({
  5830              name: 'hasKeyPair',
  5831              call: 'shh_hasKeyPair',
  5832              params: 1
  5833          }),
  5834          new Method({
  5835              name: 'getPublicKey',
  5836              call: 'shh_getPublicKey',
  5837              params: 1
  5838          }),
  5839          new Method({
  5840              name: 'getPrivateKey',
  5841              call: 'shh_getPrivateKey',
  5842              params: 1
  5843          }),
  5844          new Method({
  5845              name: 'newSymKey',
  5846              call: 'shh_newSymKey',
  5847              params: 0
  5848          }),
  5849          new Method({
  5850              name: 'addSymKey',
  5851              call: 'shh_addSymKey',
  5852              params: 1
  5853          }),
  5854          new Method({
  5855              name: 'generateSymKeyFromPassword',
  5856              call: 'shh_generateSymKeyFromPassword',
  5857              params: 1
  5858          }),
  5859          new Method({
  5860              name: 'hasSymKey',
  5861              call: 'shh_hasSymKey',
  5862              params: 1
  5863          }),
  5864          new Method({
  5865              name: 'getSymKey',
  5866              call: 'shh_getSymKey',
  5867              params: 1
  5868          }),
  5869          new Method({
  5870              name: 'deleteSymKey',
  5871              call: 'shh_deleteSymKey',
  5872              params: 1
  5873          }),
  5874  
  5875          // subscribe and unsubscribe missing
  5876  
  5877          new Method({
  5878              name: 'post',
  5879              call: 'shh_post',
  5880              params: 1,
  5881              inputFormatter: [null]
  5882          })
  5883      ];
  5884  };
  5885  
  5886  module.exports = Shh;
  5887  
  5888  
  5889  },{"../filter":29,"../method":36,"./watches":43}],42:[function(require,module,exports){
  5890  /*
  5891      This file is part of web3.js.
  5892  
  5893      web3.js is free software: you can redistribute it and/or modify
  5894      it under the terms of the GNU Lesser General Public License as published by
  5895      the Free Software Foundation, either version 3 of the License, or
  5896      (at your option) any later version.
  5897  
  5898      web3.js is distributed in the hope that it will be useful,
  5899      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5900      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5901      GNU Lesser General Public License for more details.
  5902  
  5903      You should have received a copy of the GNU Lesser General Public License
  5904      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5905  */
  5906  /**
  5907   * @file bzz.js
  5908   * @author Alex Beregszaszi <alex@rtfs.hu>
  5909   * @date 2016
  5910   *
  5911   * Reference: https://github.com/Gessiux/neatchain/blob/swarm/internal/web3ext/web3ext.go#L33
  5912   */
  5913  
  5914  "use strict";
  5915  
  5916  var Method = require('../method');
  5917  var Property = require('../property');
  5918  
  5919  function Swarm(web3) {
  5920      this._requestManager = web3._requestManager;
  5921  
  5922      var self = this;
  5923  
  5924      methods().forEach(function(method) {
  5925          method.attachToObject(self);
  5926          method.setRequestManager(self._requestManager);
  5927      });
  5928  
  5929      properties().forEach(function(p) {
  5930          p.attachToObject(self);
  5931          p.setRequestManager(self._requestManager);
  5932      });
  5933  }
  5934  
  5935  var methods = function () {
  5936      var blockNetworkRead = new Method({
  5937          name: 'blockNetworkRead',
  5938          call: 'bzz_blockNetworkRead',
  5939          params: 1,
  5940          inputFormatter: [null]
  5941      });
  5942  
  5943      var syncEnabled = new Method({
  5944          name: 'syncEnabled',
  5945          call: 'bzz_syncEnabled',
  5946          params: 1,
  5947          inputFormatter: [null]
  5948      });
  5949  
  5950      var swapEnabled = new Method({
  5951          name: 'swapEnabled',
  5952          call: 'bzz_swapEnabled',
  5953          params: 1,
  5954          inputFormatter: [null]
  5955      });
  5956  
  5957      var download = new Method({
  5958          name: 'download',
  5959          call: 'bzz_download',
  5960          params: 2,
  5961          inputFormatter: [null, null]
  5962      });
  5963  
  5964      var upload = new Method({
  5965          name: 'upload',
  5966          call: 'bzz_upload',
  5967          params: 2,
  5968          inputFormatter: [null, null]
  5969      });
  5970  
  5971      var retrieve = new Method({
  5972          name: 'retrieve',
  5973          call: 'bzz_retrieve',
  5974          params: 1,
  5975          inputFormatter: [null]
  5976      });
  5977  
  5978      var store = new Method({
  5979          name: 'store',
  5980          call: 'bzz_store',
  5981          params: 2,
  5982          inputFormatter: [null, null]
  5983      });
  5984  
  5985      var get = new Method({
  5986          name: 'get',
  5987          call: 'bzz_get',
  5988          params: 1,
  5989          inputFormatter: [null]
  5990      });
  5991  
  5992      var put = new Method({
  5993          name: 'put',
  5994          call: 'bzz_put',
  5995          params: 2,
  5996          inputFormatter: [null, null]
  5997      });
  5998  
  5999      var modify = new Method({
  6000          name: 'modify',
  6001          call: 'bzz_modify',
  6002          params: 4,
  6003          inputFormatter: [null, null, null, null]
  6004      });
  6005  
  6006      return [
  6007          blockNetworkRead,
  6008          syncEnabled,
  6009          swapEnabled,
  6010          download,
  6011          upload,
  6012          retrieve,
  6013          store,
  6014          get,
  6015          put,
  6016          modify
  6017      ];
  6018  };
  6019  
  6020  var properties = function () {
  6021      return [
  6022          new Property({
  6023              name: 'hive',
  6024              getter: 'bzz_hive'
  6025          }),
  6026          new Property({
  6027              name: 'info',
  6028              getter: 'bzz_info'
  6029          })
  6030      ];
  6031  };
  6032  
  6033  
  6034  module.exports = Swarm;
  6035  
  6036  },{"../method":36,"../property":45}],43:[function(require,module,exports){
  6037  /*
  6038      This file is part of web3.js.
  6039  
  6040      web3.js is free software: you can redistribute it and/or modify
  6041      it under the terms of the GNU Lesser General Public License as published by
  6042      the Free Software Foundation, either version 3 of the License, or
  6043      (at your option) any later version.
  6044  
  6045      web3.js is distributed in the hope that it will be useful,
  6046      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6047      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6048      GNU Lesser General Public License for more details.
  6049  
  6050      You should have received a copy of the GNU Lesser General Public License
  6051      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6052  */
  6053  /** @file watches.js
  6054   * @authors:
  6055   *   Marek Kotewicz <marek@ethdev.com>
  6056   * @date 2015
  6057   */
  6058  
  6059  var Method = require('../method');
  6060  
  6061  /// @returns an array of objects describing web3.neatptc.filter api methods
  6062  var eth = function () {
  6063      var newFilterCall = function (args) {
  6064          var type = args[0];
  6065  
  6066          switch(type) {
  6067              case 'latest':
  6068                  args.shift();
  6069                  this.params = 0;
  6070                  return 'eth_newBlockFilter';
  6071              case 'pending':
  6072                  args.shift();
  6073                  this.params = 0;
  6074                  return 'eth_newPendingTransactionFilter';
  6075              default:
  6076                  return 'eth_newFilter';
  6077          }
  6078      };
  6079  
  6080      var newFilter = new Method({
  6081          name: 'newFilter',
  6082          call: newFilterCall,
  6083          params: 1
  6084      });
  6085  
  6086      var uninstallFilter = new Method({
  6087          name: 'uninstallFilter',
  6088          call: 'eth_uninstallFilter',
  6089          params: 1
  6090      });
  6091  
  6092      var getLogs = new Method({
  6093          name: 'getLogs',
  6094          call: 'eth_getFilterLogs',
  6095          params: 1
  6096      });
  6097  
  6098      var poll = new Method({
  6099          name: 'poll',
  6100          call: 'eth_getFilterChanges',
  6101          params: 1
  6102      });
  6103  
  6104      return [
  6105          newFilter,
  6106          uninstallFilter,
  6107          getLogs,
  6108          poll
  6109      ];
  6110  };
  6111  
  6112  /// @returns an array of objects describing web3.shh.watch api methods
  6113  var shh = function () {
  6114  
  6115      return [
  6116          new Method({
  6117              name: 'newFilter',
  6118              call: 'shh_newMessageFilter',
  6119              params: 1
  6120          }),
  6121          new Method({
  6122              name: 'uninstallFilter',
  6123              call: 'shh_deleteMessageFilter',
  6124              params: 1
  6125          }),
  6126          new Method({
  6127              name: 'getLogs',
  6128              call: 'shh_getFilterMessages',
  6129              params: 1
  6130          }),
  6131          new Method({
  6132              name: 'poll',
  6133              call: 'shh_getFilterMessages',
  6134              params: 1
  6135          })
  6136      ];
  6137  };
  6138  
  6139  module.exports = {
  6140      eth: eth,
  6141      shh: shh
  6142  };
  6143  
  6144  
  6145  },{"../method":36}],44:[function(require,module,exports){
  6146  /*
  6147      This file is part of web3.js.
  6148  
  6149      web3.js is free software: you can redistribute it and/or modify
  6150      it under the terms of the GNU Lesser General Public License as published by
  6151      the Free Software Foundation, either version 3 of the License, or
  6152      (at your option) any later version.
  6153  
  6154      web3.js is distributed in the hope that it will be useful,
  6155      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6156      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6157      GNU Lesser General Public License for more details.
  6158  
  6159      You should have received a copy of the GNU Lesser General Public License
  6160      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6161  */
  6162  /** 
  6163   * @file namereg.js
  6164   * @author Marek Kotewicz <marek@ethdev.com>
  6165   * @date 2015
  6166   */
  6167  
  6168  var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  6169  var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  6170  
  6171  var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  6172  var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  6173  
  6174  module.exports = {
  6175      global: {
  6176          abi: globalRegistrarAbi,
  6177          address: globalNameregAddress
  6178      },
  6179      icap: {
  6180          abi: icapRegistrarAbi,
  6181          address: icapNameregAddress
  6182      }
  6183  };
  6184  
  6185  
  6186  },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
  6187  /*
  6188      This file is part of web3.js.
  6189  
  6190      web3.js is free software: you can redistribute it and/or modify
  6191      it under the terms of the GNU Lesser General Public License as published by
  6192      the Free Software Foundation, either version 3 of the License, or
  6193      (at your option) any later version.
  6194  
  6195      web3.js is distributed in the hope that it will be useful,
  6196      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6197      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6198      GNU Lesser General Public License for more details.
  6199  
  6200      You should have received a copy of the GNU Lesser General Public License
  6201      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6202  */
  6203  /**
  6204   * @file property.js
  6205   * @author Fabian Vogelsteller <fabian@frozeman.de>
  6206   * @author Marek Kotewicz <marek@ethdev.com>
  6207   * @date 2015
  6208   */
  6209  
  6210  var utils = require('../utils/utils');
  6211  
  6212  var Property = function (options) {
  6213      this.name = options.name;
  6214      this.getter = options.getter;
  6215      this.setter = options.setter;
  6216      this.outputFormatter = options.outputFormatter;
  6217      this.inputFormatter = options.inputFormatter;
  6218      this.requestManager = null;
  6219  };
  6220  
  6221  Property.prototype.setRequestManager = function (rm) {
  6222      this.requestManager = rm;
  6223  };
  6224  
  6225  /**
  6226   * Should be called to format input args of method
  6227   *
  6228   * @method formatInput
  6229   * @param {Array}
  6230   * @return {Array}
  6231   */
  6232  Property.prototype.formatInput = function (arg) {
  6233      return this.inputFormatter ? this.inputFormatter(arg) : arg;
  6234  };
  6235  
  6236  /**
  6237   * Should be called to format output(result) of method
  6238   *
  6239   * @method formatOutput
  6240   * @param {Object}
  6241   * @return {Object}
  6242   */
  6243  Property.prototype.formatOutput = function (result) {
  6244      return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
  6245  };
  6246  
  6247  /**
  6248   * Should be used to extract callback from array of arguments. Modifies input param
  6249   *
  6250   * @method extractCallback
  6251   * @param {Array} arguments
  6252   * @return {Function|Null} callback, if exists
  6253   */
  6254  Property.prototype.extractCallback = function (args) {
  6255      if (utils.isFunction(args[args.length - 1])) {
  6256          return args.pop(); // modify the args array!
  6257      }
  6258  };
  6259  
  6260  
  6261  /**
  6262   * Should attach function to method
  6263   *
  6264   * @method attachToObject
  6265   * @param {Object}
  6266   * @param {Function}
  6267   */
  6268  Property.prototype.attachToObject = function (obj) {
  6269      var proto = {
  6270          get: this.buildGet(),
  6271          enumerable: true
  6272      };
  6273  
  6274      var names = this.name.split('.');
  6275      var name = names[0];
  6276      if (names.length > 1) {
  6277          obj[names[0]] = obj[names[0]] || {};
  6278          obj = obj[names[0]];
  6279          name = names[1];
  6280      }
  6281  
  6282      Object.defineProperty(obj, name, proto);
  6283      obj[asyncGetterName(name)] = this.buildAsyncGet();
  6284  };
  6285  
  6286  var asyncGetterName = function (name) {
  6287      return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  6288  };
  6289  
  6290  Property.prototype.buildGet = function () {
  6291      var property = this;
  6292      return function get() {
  6293          return property.formatOutput(property.requestManager.send({
  6294              method: property.getter
  6295          }));
  6296      };
  6297  };
  6298  
  6299  Property.prototype.buildAsyncGet = function () {
  6300      var property = this;
  6301      var get = function (callback) {
  6302          property.requestManager.sendAsync({
  6303              method: property.getter
  6304          }, function (err, result) {
  6305              callback(err, property.formatOutput(result));
  6306          });
  6307      };
  6308      get.request = this.request.bind(this);
  6309      return get;
  6310  };
  6311  
  6312  /**
  6313   * Should be called to create pure JSONRPC request which can be used in batch request
  6314   *
  6315   * @method request
  6316   * @param {...} params
  6317   * @return {Object} jsonrpc request
  6318   */
  6319  Property.prototype.request = function () {
  6320      var payload = {
  6321          method: this.getter,
  6322          params: [],
  6323          callback: this.extractCallback(Array.prototype.slice.call(arguments))
  6324      };
  6325      payload.format = this.formatOutput.bind(this);
  6326      return payload;
  6327  };
  6328  
  6329  module.exports = Property;
  6330  
  6331  
  6332  },{"../utils/utils":20}],46:[function(require,module,exports){
  6333  /*
  6334      This file is part of web3.js.
  6335  
  6336      web3.js is free software: you can redistribute it and/or modify
  6337      it under the terms of the GNU Lesser General Public License as published by
  6338      the Free Software Foundation, either version 3 of the License, or
  6339      (at your option) any later version.
  6340  
  6341      web3.js is distributed in the hope that it will be useful,
  6342      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6343      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6344      GNU Lesser General Public License for more details.
  6345  
  6346      You should have received a copy of the GNU Lesser General Public License
  6347      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6348  */
  6349  /** 
  6350   * @file requestmanager.js
  6351   * @author Jeffrey Wilcke <jeff@ethdev.com>
  6352   * @author Marek Kotewicz <marek@ethdev.com>
  6353   * @author Marian Oancea <marian@ethdev.com>
  6354   * @author Fabian Vogelsteller <fabian@ethdev.com>
  6355   * @author Gav Wood <g@ethdev.com>
  6356   * @date 2014
  6357   */
  6358  
  6359  var Jsonrpc = require('./jsonrpc');
  6360  var utils = require('../utils/utils');
  6361  var c = require('../utils/config');
  6362  var errors = require('./errors');
  6363  
  6364  /**
  6365   * It's responsible for passing messages to providers
  6366   * It's also responsible for polling the ethereum node for incoming messages
  6367   * Default poll timeout is 1 second
  6368   * Singleton
  6369   */
  6370  var RequestManager = function (provider) {
  6371      this.provider = provider;
  6372      this.polls = {};
  6373      this.timeout = null;
  6374  };
  6375  
  6376  /**
  6377   * Should be used to synchronously send request
  6378   *
  6379   * @method send
  6380   * @param {Object} data
  6381   * @return {Object}
  6382   */
  6383  RequestManager.prototype.send = function (data) {
  6384      if (!this.provider) {
  6385          console.error(errors.InvalidProvider());
  6386          return null;
  6387      }
  6388  
  6389      var payload = Jsonrpc.toPayload(data.method, data.params);
  6390      var result = this.provider.send(payload);
  6391  
  6392      if (!Jsonrpc.isValidResponse(result)) {
  6393          throw errors.InvalidResponse(result);
  6394      }
  6395  
  6396      return result.result;
  6397  };
  6398  
  6399  /**
  6400   * Should be used to asynchronously send request
  6401   *
  6402   * @method sendAsync
  6403   * @param {Object} data
  6404   * @param {Function} callback
  6405   */
  6406  RequestManager.prototype.sendAsync = function (data, callback) {
  6407      if (!this.provider) {
  6408          return callback(errors.InvalidProvider());
  6409      }
  6410  
  6411      var payload = Jsonrpc.toPayload(data.method, data.params);
  6412      this.provider.sendAsync(payload, function (err, result) {
  6413          if (err) {
  6414              return callback(err);
  6415          }
  6416          
  6417          if (!Jsonrpc.isValidResponse(result)) {
  6418              return callback(errors.InvalidResponse(result));
  6419          }
  6420  
  6421          callback(null, result.result);
  6422      });
  6423  };
  6424  
  6425  /**
  6426   * Should be called to asynchronously send batch request
  6427   *
  6428   * @method sendBatch
  6429   * @param {Array} batch data
  6430   * @param {Function} callback
  6431   */
  6432  RequestManager.prototype.sendBatch = function (data, callback) {
  6433      if (!this.provider) {
  6434          return callback(errors.InvalidProvider());
  6435      }
  6436  
  6437      var payload = Jsonrpc.toBatchPayload(data);
  6438  
  6439      this.provider.sendAsync(payload, function (err, results) {
  6440          if (err) {
  6441              return callback(err);
  6442          }
  6443  
  6444          if (!utils.isArray(results)) {
  6445              return callback(errors.InvalidResponse(results));
  6446          }
  6447  
  6448          callback(err, results);
  6449      }); 
  6450  };
  6451  
  6452  /**
  6453   * Should be used to set provider of request manager
  6454   *
  6455   * @method setProvider
  6456   * @param {Object}
  6457   */
  6458  RequestManager.prototype.setProvider = function (p) {
  6459      this.provider = p;
  6460  };
  6461  
  6462  /**
  6463   * Should be used to start polling
  6464   *
  6465   * @method startPolling
  6466   * @param {Object} data
  6467   * @param {Number} pollId
  6468   * @param {Function} callback
  6469   * @param {Function} uninstall
  6470   *
  6471   * @todo cleanup number of params
  6472   */
  6473  RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  6474      this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  6475  
  6476  
  6477      // start polling
  6478      if (!this.timeout) {
  6479          this.poll();
  6480      }
  6481  };
  6482  
  6483  /**
  6484   * Should be used to stop polling for filter with given id
  6485   *
  6486   * @method stopPolling
  6487   * @param {Number} pollId
  6488   */
  6489  RequestManager.prototype.stopPolling = function (pollId) {
  6490      delete this.polls[pollId];
  6491  
  6492      // stop polling
  6493      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6494          clearTimeout(this.timeout);
  6495          this.timeout = null;
  6496      }
  6497  };
  6498  
  6499  /**
  6500   * Should be called to reset the polling mechanism of the request manager
  6501   *
  6502   * @method reset
  6503   */
  6504  RequestManager.prototype.reset = function (keepIsSyncing) {
  6505      /*jshint maxcomplexity:5 */
  6506  
  6507      for (var key in this.polls) {
  6508          // remove all polls, except sync polls,
  6509          // they need to be removed manually by calling syncing.stopWatching()
  6510          if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  6511              this.polls[key].uninstall();
  6512              delete this.polls[key];
  6513          }
  6514      }
  6515  
  6516      // stop polling
  6517      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6518          clearTimeout(this.timeout);
  6519          this.timeout = null;
  6520      }
  6521  };
  6522  
  6523  /**
  6524   * Should be called to poll for changes on filter with given id
  6525   *
  6526   * @method poll
  6527   */
  6528  RequestManager.prototype.poll = function () {
  6529      /*jshint maxcomplexity: 6 */
  6530      this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  6531  
  6532      if (Object.keys(this.polls).length === 0) {
  6533          return;
  6534      }
  6535  
  6536      if (!this.provider) {
  6537          console.error(errors.InvalidProvider());
  6538          return;
  6539      }
  6540  
  6541      var pollsData = [];
  6542      var pollsIds = [];
  6543      for (var key in this.polls) {
  6544          pollsData.push(this.polls[key].data);
  6545          pollsIds.push(key);
  6546      }
  6547  
  6548      if (pollsData.length === 0) {
  6549          return;
  6550      }
  6551  
  6552      var payload = Jsonrpc.toBatchPayload(pollsData);
  6553      
  6554      // map the request id to they poll id
  6555      var pollsIdMap = {};
  6556      payload.forEach(function(load, index){
  6557          pollsIdMap[load.id] = pollsIds[index];
  6558      });
  6559  
  6560  
  6561      var self = this;
  6562      this.provider.sendAsync(payload, function (error, results) {
  6563  
  6564  
  6565          // TODO: console log?
  6566          if (error) {
  6567              return;
  6568          }
  6569  
  6570          if (!utils.isArray(results)) {
  6571              throw errors.InvalidResponse(results);
  6572          }
  6573          results.map(function (result) {
  6574              var id = pollsIdMap[result.id];
  6575  
  6576              // make sure the filter is still installed after arrival of the request
  6577              if (self.polls[id]) {
  6578                  result.callback = self.polls[id].callback;
  6579                  return result;
  6580              } else
  6581                  return false;
  6582          }).filter(function (result) {
  6583              return !!result; 
  6584          }).filter(function (result) {
  6585              var valid = Jsonrpc.isValidResponse(result);
  6586              if (!valid) {
  6587                  result.callback(errors.InvalidResponse(result));
  6588              }
  6589              return valid;
  6590          }).forEach(function (result) {
  6591              result.callback(null, result.result);
  6592          });
  6593      });
  6594  };
  6595  
  6596  module.exports = RequestManager;
  6597  
  6598  
  6599  },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
  6600  
  6601  
  6602  var Settings = function () {
  6603      this.defaultBlock = 'latest';
  6604      this.defaultAccount = undefined;
  6605  };
  6606  
  6607  module.exports = Settings;
  6608  
  6609  
  6610  },{}],48:[function(require,module,exports){
  6611  /*
  6612      This file is part of web3.js.
  6613  
  6614      web3.js is free software: you can redistribute it and/or modify
  6615      it under the terms of the GNU Lesser General Public License as published by
  6616      the Free Software Foundation, either version 3 of the License, or
  6617      (at your option) any later version.
  6618  
  6619      web3.js is distributed in the hope that it will be useful,
  6620      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6621      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6622      GNU Lesser General Public License for more details.
  6623  
  6624      You should have received a copy of the GNU Lesser General Public License
  6625      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6626  */
  6627  /** @file syncing.js
  6628   * @authors:
  6629   *   Fabian Vogelsteller <fabian@ethdev.com>
  6630   * @date 2015
  6631   */
  6632  
  6633  var formatters = require('./formatters');
  6634  var utils = require('../utils/utils');
  6635  
  6636  var count = 1;
  6637  
  6638  /**
  6639  Adds the callback and sets up the methods, to iterate over the results.
  6640  
  6641  @method pollSyncing
  6642  @param {Object} self
  6643  */
  6644  var pollSyncing = function(self) {
  6645  
  6646      var onMessage = function (error, sync) {
  6647          if (error) {
  6648              return self.callbacks.forEach(function (callback) {
  6649                  callback(error);
  6650              });
  6651          }
  6652  
  6653          if(utils.isObject(sync) && sync.startingBlock)
  6654              sync = formatters.outputSyncingFormatter(sync);
  6655  
  6656          self.callbacks.forEach(function (callback) {
  6657              if (self.lastSyncState !== sync) {
  6658                  
  6659                  // call the callback with true first so the app can stop anything, before receiving the sync data
  6660                  if(!self.lastSyncState && utils.isObject(sync))
  6661                      callback(null, true);
  6662                  
  6663                  // call on the next CPU cycle, so the actions of the sync stop can be processes first
  6664                  setTimeout(function() {
  6665                      callback(null, sync);
  6666                  }, 0);
  6667                  
  6668                  self.lastSyncState = sync;
  6669              }
  6670          });
  6671      };
  6672  
  6673      self.requestManager.startPolling({
  6674          method: 'eth_syncing',
  6675          params: [],
  6676      }, self.pollId, onMessage, self.stopWatching.bind(self));
  6677  
  6678  };
  6679  
  6680  var IsSyncing = function (requestManager, callback) {
  6681      this.requestManager = requestManager;
  6682      this.pollId = 'syncPoll_'+ count++;
  6683      this.callbacks = [];
  6684      this.addCallback(callback);
  6685      this.lastSyncState = false;
  6686      pollSyncing(this);
  6687  
  6688      return this;
  6689  };
  6690  
  6691  IsSyncing.prototype.addCallback = function (callback) {
  6692      if(callback)
  6693          this.callbacks.push(callback);
  6694      return this;
  6695  };
  6696  
  6697  IsSyncing.prototype.stopWatching = function () {
  6698      this.requestManager.stopPolling(this.pollId);
  6699      this.callbacks = [];
  6700  };
  6701  
  6702  module.exports = IsSyncing;
  6703  
  6704  
  6705  },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
  6706  /*
  6707      This file is part of web3.js.
  6708  
  6709      web3.js is free software: you can redistribute it and/or modify
  6710      it under the terms of the GNU Lesser General Public License as published by
  6711      the Free Software Foundation, either version 3 of the License, or
  6712      (at your option) any later version.
  6713  
  6714      web3.js is distributed in the hope that it will be useful,
  6715      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6716      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6717      GNU Lesser General Public License for more details.
  6718  
  6719      You should have received a copy of the GNU Lesser General Public License
  6720      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6721  */
  6722  /** 
  6723   * @file transfer.js
  6724   * @author Marek Kotewicz <marek@ethdev.com>
  6725   * @date 2015
  6726   */
  6727  
  6728  var Iban = require('./iban');
  6729  var exchangeAbi = require('../contracts/SmartExchange.json');
  6730  
  6731  /**
  6732   * Should be used to make Iban transfer
  6733   *
  6734   * @method transfer
  6735   * @param {String} from
  6736   * @param {String} to iban
  6737   * @param {Value} value to be tranfered
  6738   * @param {Function} callback, callback
  6739   */
  6740  var transfer = function (eth, from, to, value, callback) {
  6741      var iban = new Iban(to); 
  6742      if (!iban.isValid()) {
  6743          throw new Error('invalid iban address');
  6744      }
  6745  
  6746      if (iban.isDirect()) {
  6747          return transferToAddress(eth, from, iban.address(), value, callback);
  6748      }
  6749      
  6750      if (!callback) {
  6751          var address = eth.icapNamereg().addr(iban.institution());
  6752          return deposit(eth, from, address, value, iban.client());
  6753      }
  6754  
  6755      eth.icapNamereg().addr(iban.institution(), function (err, address) {
  6756          return deposit(eth, from, address, value, iban.client(), callback);
  6757      });
  6758      
  6759  };
  6760  
  6761  /**
  6762   * Should be used to transfer funds to certain address
  6763   *
  6764   * @method transferToAddress
  6765   * @param {String} from
  6766   * @param {String} to
  6767   * @param {Value} value to be tranfered
  6768   * @param {Function} callback, callback
  6769   */
  6770  var transferToAddress = function (eth, from, to, value, callback) {
  6771      return eth.sendTransaction({
  6772          address: to,
  6773          from: from,
  6774          value: value
  6775      }, callback);
  6776  };
  6777  
  6778  /**
  6779   * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  6780   *
  6781   * @method deposit
  6782   * @param {String} from
  6783   * @param {String} to
  6784   * @param {Value} value to be transfered
  6785   * @param {String} client unique identifier
  6786   * @param {Function} callback, callback
  6787   */
  6788  var deposit = function (eth, from, to, value, client, callback) {
  6789      var abi = exchangeAbi;
  6790      return eth.contract(abi).at(to).deposit(client, {
  6791          from: from,
  6792          value: value
  6793      }, callback);
  6794  };
  6795  
  6796  module.exports = transfer;
  6797  
  6798  
  6799  },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
  6800  
  6801  },{}],51:[function(require,module,exports){
  6802  ;(function (root, factory, undef) {
  6803  	if (typeof exports === "object") {
  6804  		// CommonJS
  6805  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  6806  	}
  6807  	else if (typeof define === "function" && define.amd) {
  6808  		// AMD
  6809  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  6810  	}
  6811  	else {
  6812  		// Global (browser)
  6813  		factory(root.CryptoJS);
  6814  	}
  6815  }(this, function (CryptoJS) {
  6816  
  6817  	(function () {
  6818  	    // Shortcuts
  6819  	    var C = CryptoJS;
  6820  	    var C_lib = C.lib;
  6821  	    var BlockCipher = C_lib.BlockCipher;
  6822  	    var C_algo = C.algo;
  6823  
  6824  	    // Lookup tables
  6825  	    var SBOX = [];
  6826  	    var INV_SBOX = [];
  6827  	    var SUB_MIX_0 = [];
  6828  	    var SUB_MIX_1 = [];
  6829  	    var SUB_MIX_2 = [];
  6830  	    var SUB_MIX_3 = [];
  6831  	    var INV_SUB_MIX_0 = [];
  6832  	    var INV_SUB_MIX_1 = [];
  6833  	    var INV_SUB_MIX_2 = [];
  6834  	    var INV_SUB_MIX_3 = [];
  6835  
  6836  	    // Compute lookup tables
  6837  	    (function () {
  6838  	        // Compute double table
  6839  	        var d = [];
  6840  	        for (var i = 0; i < 256; i++) {
  6841  	            if (i < 128) {
  6842  	                d[i] = i << 1;
  6843  	            } else {
  6844  	                d[i] = (i << 1) ^ 0x11b;
  6845  	            }
  6846  	        }
  6847  
  6848  	        // Walk GF(2^8)
  6849  	        var x = 0;
  6850  	        var xi = 0;
  6851  	        for (var i = 0; i < 256; i++) {
  6852  	            // Compute sbox
  6853  	            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6854  	            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6855  	            SBOX[x] = sx;
  6856  	            INV_SBOX[sx] = x;
  6857  
  6858  	            // Compute multiplication
  6859  	            var x2 = d[x];
  6860  	            var x4 = d[x2];
  6861  	            var x8 = d[x4];
  6862  
  6863  	            // Compute sub bytes, mix columns tables
  6864  	            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6865  	            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  6866  	            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  6867  	            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
  6868  	            SUB_MIX_3[x] = t;
  6869  
  6870  	            // Compute inv sub bytes, inv mix columns tables
  6871  	            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6872  	            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  6873  	            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  6874  	            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
  6875  	            INV_SUB_MIX_3[sx] = t;
  6876  
  6877  	            // Compute next counter
  6878  	            if (!x) {
  6879  	                x = xi = 1;
  6880  	            } else {
  6881  	                x = x2 ^ d[d[d[x8 ^ x2]]];
  6882  	                xi ^= d[d[xi]];
  6883  	            }
  6884  	        }
  6885  	    }());
  6886  
  6887  	    // Precomputed Rcon lookup
  6888  	    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6889  
  6890  	    /**
  6891  	     * AES block cipher algorithm.
  6892  	     */
  6893  	    var AES = C_algo.AES = BlockCipher.extend({
  6894  	        _doReset: function () {
  6895  	            // Skip reset of nRounds has been set before and key did not change
  6896  	            if (this._nRounds && this._keyPriorReset === this._key) {
  6897  	                return;
  6898  	            }
  6899  
  6900  	            // Shortcuts
  6901  	            var key = this._keyPriorReset = this._key;
  6902  	            var keyWords = key.words;
  6903  	            var keySize = key.sigBytes / 4;
  6904  
  6905  	            // Compute number of rounds
  6906  	            var nRounds = this._nRounds = keySize + 6;
  6907  
  6908  	            // Compute number of key schedule rows
  6909  	            var ksRows = (nRounds + 1) * 4;
  6910  
  6911  	            // Compute key schedule
  6912  	            var keySchedule = this._keySchedule = [];
  6913  	            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  6914  	                if (ksRow < keySize) {
  6915  	                    keySchedule[ksRow] = keyWords[ksRow];
  6916  	                } else {
  6917  	                    var t = keySchedule[ksRow - 1];
  6918  
  6919  	                    if (!(ksRow % keySize)) {
  6920  	                        // Rot word
  6921  	                        t = (t << 8) | (t >>> 24);
  6922  
  6923  	                        // Sub word
  6924  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6925  
  6926  	                        // Mix Rcon
  6927  	                        t ^= RCON[(ksRow / keySize) | 0] << 24;
  6928  	                    } else if (keySize > 6 && ksRow % keySize == 4) {
  6929  	                        // Sub word
  6930  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6931  	                    }
  6932  
  6933  	                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  6934  	                }
  6935  	            }
  6936  
  6937  	            // Compute inv key schedule
  6938  	            var invKeySchedule = this._invKeySchedule = [];
  6939  	            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  6940  	                var ksRow = ksRows - invKsRow;
  6941  
  6942  	                if (invKsRow % 4) {
  6943  	                    var t = keySchedule[ksRow];
  6944  	                } else {
  6945  	                    var t = keySchedule[ksRow - 4];
  6946  	                }
  6947  
  6948  	                if (invKsRow < 4 || ksRow <= 4) {
  6949  	                    invKeySchedule[invKsRow] = t;
  6950  	                } else {
  6951  	                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  6952  	                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  6953  	                }
  6954  	            }
  6955  	        },
  6956  
  6957  	        encryptBlock: function (M, offset) {
  6958  	            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  6959  	        },
  6960  
  6961  	        decryptBlock: function (M, offset) {
  6962  	            // Swap 2nd and 4th rows
  6963  	            var t = M[offset + 1];
  6964  	            M[offset + 1] = M[offset + 3];
  6965  	            M[offset + 3] = t;
  6966  
  6967  	            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  6968  
  6969  	            // Inv swap 2nd and 4th rows
  6970  	            var t = M[offset + 1];
  6971  	            M[offset + 1] = M[offset + 3];
  6972  	            M[offset + 3] = t;
  6973  	        },
  6974  
  6975  	        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  6976  	            // Shortcut
  6977  	            var nRounds = this._nRounds;
  6978  
  6979  	            // Get input, add round key
  6980  	            var s0 = M[offset]     ^ keySchedule[0];
  6981  	            var s1 = M[offset + 1] ^ keySchedule[1];
  6982  	            var s2 = M[offset + 2] ^ keySchedule[2];
  6983  	            var s3 = M[offset + 3] ^ keySchedule[3];
  6984  
  6985  	            // Key schedule row counter
  6986  	            var ksRow = 4;
  6987  
  6988  	            // Rounds
  6989  	            for (var round = 1; round < nRounds; round++) {
  6990  	                // Shift rows, sub bytes, mix columns, add round key
  6991  	                var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  6992  	                var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  6993  	                var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  6994  	                var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  6995  
  6996  	                // Update state
  6997  	                s0 = t0;
  6998  	                s1 = t1;
  6999  	                s2 = t2;
  7000  	                s3 = t3;
  7001  	            }
  7002  
  7003  	            // Shift rows, sub bytes, add round key
  7004  	            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  7005  	            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  7006  	            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  7007  	            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  7008  
  7009  	            // Set output
  7010  	            M[offset]     = t0;
  7011  	            M[offset + 1] = t1;
  7012  	            M[offset + 2] = t2;
  7013  	            M[offset + 3] = t3;
  7014  	        },
  7015  
  7016  	        keySize: 256/32
  7017  	    });
  7018  
  7019  	    /**
  7020  	     * Shortcut functions to the cipher's object interface.
  7021  	     *
  7022  	     * @example
  7023  	     *
  7024  	     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  7025  	     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  7026  	     */
  7027  	    C.AES = BlockCipher._createHelper(AES);
  7028  	}());
  7029  
  7030  
  7031  	return CryptoJS.AES;
  7032  
  7033  }));
  7034  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
  7035  ;(function (root, factory) {
  7036  	if (typeof exports === "object") {
  7037  		// CommonJS
  7038  		module.exports = exports = factory(require("./core"));
  7039  	}
  7040  	else if (typeof define === "function" && define.amd) {
  7041  		// AMD
  7042  		define(["./core"], factory);
  7043  	}
  7044  	else {
  7045  		// Global (browser)
  7046  		factory(root.CryptoJS);
  7047  	}
  7048  }(this, function (CryptoJS) {
  7049  
  7050  	/**
  7051  	 * Cipher core components.
  7052  	 */
  7053  	CryptoJS.lib.Cipher || (function (undefined) {
  7054  	    // Shortcuts
  7055  	    var C = CryptoJS;
  7056  	    var C_lib = C.lib;
  7057  	    var Base = C_lib.Base;
  7058  	    var WordArray = C_lib.WordArray;
  7059  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  7060  	    var C_enc = C.enc;
  7061  	    var Utf8 = C_enc.Utf8;
  7062  	    var Base64 = C_enc.Base64;
  7063  	    var C_algo = C.algo;
  7064  	    var EvpKDF = C_algo.EvpKDF;
  7065  
  7066  	    /**
  7067  	     * Abstract base cipher template.
  7068  	     *
  7069  	     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  7070  	     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  7071  	     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  7072  	     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  7073  	     */
  7074  	    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  7075  	        /**
  7076  	         * Configuration options.
  7077  	         *
  7078  	         * @property {WordArray} iv The IV to use for this operation.
  7079  	         */
  7080  	        cfg: Base.extend(),
  7081  
  7082  	        /**
  7083  	         * Creates this cipher in encryption mode.
  7084  	         *
  7085  	         * @param {WordArray} key The key.
  7086  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7087  	         *
  7088  	         * @return {Cipher} A cipher instance.
  7089  	         *
  7090  	         * @static
  7091  	         *
  7092  	         * @example
  7093  	         *
  7094  	         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  7095  	         */
  7096  	        createEncryptor: function (key, cfg) {
  7097  	            return this.create(this._ENC_XFORM_MODE, key, cfg);
  7098  	        },
  7099  
  7100  	        /**
  7101  	         * Creates this cipher in decryption mode.
  7102  	         *
  7103  	         * @param {WordArray} key The key.
  7104  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7105  	         *
  7106  	         * @return {Cipher} A cipher instance.
  7107  	         *
  7108  	         * @static
  7109  	         *
  7110  	         * @example
  7111  	         *
  7112  	         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  7113  	         */
  7114  	        createDecryptor: function (key, cfg) {
  7115  	            return this.create(this._DEC_XFORM_MODE, key, cfg);
  7116  	        },
  7117  
  7118  	        /**
  7119  	         * Initializes a newly created cipher.
  7120  	         *
  7121  	         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  7122  	         * @param {WordArray} key The key.
  7123  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7124  	         *
  7125  	         * @example
  7126  	         *
  7127  	         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  7128  	         */
  7129  	        init: function (xformMode, key, cfg) {
  7130  	            // Apply config defaults
  7131  	            this.cfg = this.cfg.extend(cfg);
  7132  
  7133  	            // Store transform mode and key
  7134  	            this._xformMode = xformMode;
  7135  	            this._key = key;
  7136  
  7137  	            // Set initial values
  7138  	            this.reset();
  7139  	        },
  7140  
  7141  	        /**
  7142  	         * Resets this cipher to its initial state.
  7143  	         *
  7144  	         * @example
  7145  	         *
  7146  	         *     cipher.reset();
  7147  	         */
  7148  	        reset: function () {
  7149  	            // Reset data buffer
  7150  	            BufferedBlockAlgorithm.reset.call(this);
  7151  
  7152  	            // Perform concrete-cipher logic
  7153  	            this._doReset();
  7154  	        },
  7155  
  7156  	        /**
  7157  	         * Adds data to be encrypted or decrypted.
  7158  	         *
  7159  	         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  7160  	         *
  7161  	         * @return {WordArray} The data after processing.
  7162  	         *
  7163  	         * @example
  7164  	         *
  7165  	         *     var encrypted = cipher.process('data');
  7166  	         *     var encrypted = cipher.process(wordArray);
  7167  	         */
  7168  	        process: function (dataUpdate) {
  7169  	            // Append
  7170  	            this._append(dataUpdate);
  7171  
  7172  	            // Process available blocks
  7173  	            return this._process();
  7174  	        },
  7175  
  7176  	        /**
  7177  	         * Finalizes the encryption or decryption process.
  7178  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  7179  	         *
  7180  	         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  7181  	         *
  7182  	         * @return {WordArray} The data after final processing.
  7183  	         *
  7184  	         * @example
  7185  	         *
  7186  	         *     var encrypted = cipher.finalize();
  7187  	         *     var encrypted = cipher.finalize('data');
  7188  	         *     var encrypted = cipher.finalize(wordArray);
  7189  	         */
  7190  	        finalize: function (dataUpdate) {
  7191  	            // Final data update
  7192  	            if (dataUpdate) {
  7193  	                this._append(dataUpdate);
  7194  	            }
  7195  
  7196  	            // Perform concrete-cipher logic
  7197  	            var finalProcessedData = this._doFinalize();
  7198  
  7199  	            return finalProcessedData;
  7200  	        },
  7201  
  7202  	        keySize: 128/32,
  7203  
  7204  	        ivSize: 128/32,
  7205  
  7206  	        _ENC_XFORM_MODE: 1,
  7207  
  7208  	        _DEC_XFORM_MODE: 2,
  7209  
  7210  	        /**
  7211  	         * Creates shortcut functions to a cipher's object interface.
  7212  	         *
  7213  	         * @param {Cipher} cipher The cipher to create a helper for.
  7214  	         *
  7215  	         * @return {Object} An object with encrypt and decrypt shortcut functions.
  7216  	         *
  7217  	         * @static
  7218  	         *
  7219  	         * @example
  7220  	         *
  7221  	         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  7222  	         */
  7223  	        _createHelper: (function () {
  7224  	            function selectCipherStrategy(key) {
  7225  	                if (typeof key == 'string') {
  7226  	                    return PasswordBasedCipher;
  7227  	                } else {
  7228  	                    return SerializableCipher;
  7229  	                }
  7230  	            }
  7231  
  7232  	            return function (cipher) {
  7233  	                return {
  7234  	                    encrypt: function (message, key, cfg) {
  7235  	                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  7236  	                    },
  7237  
  7238  	                    decrypt: function (ciphertext, key, cfg) {
  7239  	                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  7240  	                    }
  7241  	                };
  7242  	            };
  7243  	        }())
  7244  	    });
  7245  
  7246  	    /**
  7247  	     * Abstract base stream cipher template.
  7248  	     *
  7249  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  7250  	     */
  7251  	    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  7252  	        _doFinalize: function () {
  7253  	            // Process partial blocks
  7254  	            var finalProcessedBlocks = this._process(!!'flush');
  7255  
  7256  	            return finalProcessedBlocks;
  7257  	        },
  7258  
  7259  	        blockSize: 1
  7260  	    });
  7261  
  7262  	    /**
  7263  	     * Mode namespace.
  7264  	     */
  7265  	    var C_mode = C.mode = {};
  7266  
  7267  	    /**
  7268  	     * Abstract base block cipher mode template.
  7269  	     */
  7270  	    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  7271  	        /**
  7272  	         * Creates this mode for encryption.
  7273  	         *
  7274  	         * @param {Cipher} cipher A block cipher instance.
  7275  	         * @param {Array} iv The IV words.
  7276  	         *
  7277  	         * @static
  7278  	         *
  7279  	         * @example
  7280  	         *
  7281  	         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  7282  	         */
  7283  	        createEncryptor: function (cipher, iv) {
  7284  	            return this.Encryptor.create(cipher, iv);
  7285  	        },
  7286  
  7287  	        /**
  7288  	         * Creates this mode for decryption.
  7289  	         *
  7290  	         * @param {Cipher} cipher A block cipher instance.
  7291  	         * @param {Array} iv The IV words.
  7292  	         *
  7293  	         * @static
  7294  	         *
  7295  	         * @example
  7296  	         *
  7297  	         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  7298  	         */
  7299  	        createDecryptor: function (cipher, iv) {
  7300  	            return this.Decryptor.create(cipher, iv);
  7301  	        },
  7302  
  7303  	        /**
  7304  	         * Initializes a newly created mode.
  7305  	         *
  7306  	         * @param {Cipher} cipher A block cipher instance.
  7307  	         * @param {Array} iv The IV words.
  7308  	         *
  7309  	         * @example
  7310  	         *
  7311  	         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  7312  	         */
  7313  	        init: function (cipher, iv) {
  7314  	            this._cipher = cipher;
  7315  	            this._iv = iv;
  7316  	        }
  7317  	    });
  7318  
  7319  	    /**
  7320  	     * Cipher Block Chaining mode.
  7321  	     */
  7322  	    var CBC = C_mode.CBC = (function () {
  7323  	        /**
  7324  	         * Abstract base CBC mode.
  7325  	         */
  7326  	        var CBC = BlockCipherMode.extend();
  7327  
  7328  	        /**
  7329  	         * CBC encryptor.
  7330  	         */
  7331  	        CBC.Encryptor = CBC.extend({
  7332  	            /**
  7333  	             * Processes the data block at offset.
  7334  	             *
  7335  	             * @param {Array} words The data words to operate on.
  7336  	             * @param {number} offset The offset where the block starts.
  7337  	             *
  7338  	             * @example
  7339  	             *
  7340  	             *     mode.processBlock(data.words, offset);
  7341  	             */
  7342  	            processBlock: function (words, offset) {
  7343  	                // Shortcuts
  7344  	                var cipher = this._cipher;
  7345  	                var blockSize = cipher.blockSize;
  7346  
  7347  	                // XOR and encrypt
  7348  	                xorBlock.call(this, words, offset, blockSize);
  7349  	                cipher.encryptBlock(words, offset);
  7350  
  7351  	                // Remember this block to use with next block
  7352  	                this._prevBlock = words.slice(offset, offset + blockSize);
  7353  	            }
  7354  	        });
  7355  
  7356  	        /**
  7357  	         * CBC decryptor.
  7358  	         */
  7359  	        CBC.Decryptor = CBC.extend({
  7360  	            /**
  7361  	             * Processes the data block at offset.
  7362  	             *
  7363  	             * @param {Array} words The data words to operate on.
  7364  	             * @param {number} offset The offset where the block starts.
  7365  	             *
  7366  	             * @example
  7367  	             *
  7368  	             *     mode.processBlock(data.words, offset);
  7369  	             */
  7370  	            processBlock: function (words, offset) {
  7371  	                // Shortcuts
  7372  	                var cipher = this._cipher;
  7373  	                var blockSize = cipher.blockSize;
  7374  
  7375  	                // Remember this block to use with next block
  7376  	                var thisBlock = words.slice(offset, offset + blockSize);
  7377  
  7378  	                // Decrypt and XOR
  7379  	                cipher.decryptBlock(words, offset);
  7380  	                xorBlock.call(this, words, offset, blockSize);
  7381  
  7382  	                // This block becomes the previous block
  7383  	                this._prevBlock = thisBlock;
  7384  	            }
  7385  	        });
  7386  
  7387  	        function xorBlock(words, offset, blockSize) {
  7388  	            // Shortcut
  7389  	            var iv = this._iv;
  7390  
  7391  	            // Choose mixing block
  7392  	            if (iv) {
  7393  	                var block = iv;
  7394  
  7395  	                // Remove IV for subsequent blocks
  7396  	                this._iv = undefined;
  7397  	            } else {
  7398  	                var block = this._prevBlock;
  7399  	            }
  7400  
  7401  	            // XOR blocks
  7402  	            for (var i = 0; i < blockSize; i++) {
  7403  	                words[offset + i] ^= block[i];
  7404  	            }
  7405  	        }
  7406  
  7407  	        return CBC;
  7408  	    }());
  7409  
  7410  	    /**
  7411  	     * Padding namespace.
  7412  	     */
  7413  	    var C_pad = C.pad = {};
  7414  
  7415  	    /**
  7416  	     * PKCS #5/7 padding strategy.
  7417  	     */
  7418  	    var Pkcs7 = C_pad.Pkcs7 = {
  7419  	        /**
  7420  	         * Pads data using the algorithm defined in PKCS #5/7.
  7421  	         *
  7422  	         * @param {WordArray} data The data to pad.
  7423  	         * @param {number} blockSize The multiple that the data should be padded to.
  7424  	         *
  7425  	         * @static
  7426  	         *
  7427  	         * @example
  7428  	         *
  7429  	         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  7430  	         */
  7431  	        pad: function (data, blockSize) {
  7432  	            // Shortcut
  7433  	            var blockSizeBytes = blockSize * 4;
  7434  
  7435  	            // Count padding bytes
  7436  	            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  7437  
  7438  	            // Create padding word
  7439  	            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  7440  
  7441  	            // Create padding
  7442  	            var paddingWords = [];
  7443  	            for (var i = 0; i < nPaddingBytes; i += 4) {
  7444  	                paddingWords.push(paddingWord);
  7445  	            }
  7446  	            var padding = WordArray.create(paddingWords, nPaddingBytes);
  7447  
  7448  	            // Add padding
  7449  	            data.concat(padding);
  7450  	        },
  7451  
  7452  	        /**
  7453  	         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  7454  	         *
  7455  	         * @param {WordArray} data The data to unpad.
  7456  	         *
  7457  	         * @static
  7458  	         *
  7459  	         * @example
  7460  	         *
  7461  	         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
  7462  	         */
  7463  	        unpad: function (data) {
  7464  	            // Get number of padding bytes from last byte
  7465  	            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  7466  
  7467  	            // Remove padding
  7468  	            data.sigBytes -= nPaddingBytes;
  7469  	        }
  7470  	    };
  7471  
  7472  	    /**
  7473  	     * Abstract base block cipher template.
  7474  	     *
  7475  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  7476  	     */
  7477  	    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  7478  	        /**
  7479  	         * Configuration options.
  7480  	         *
  7481  	         * @property {Mode} mode The block mode to use. Default: CBC
  7482  	         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  7483  	         */
  7484  	        cfg: Cipher.cfg.extend({
  7485  	            mode: CBC,
  7486  	            padding: Pkcs7
  7487  	        }),
  7488  
  7489  	        reset: function () {
  7490  	            // Reset cipher
  7491  	            Cipher.reset.call(this);
  7492  
  7493  	            // Shortcuts
  7494  	            var cfg = this.cfg;
  7495  	            var iv = cfg.iv;
  7496  	            var mode = cfg.mode;
  7497  
  7498  	            // Reset block mode
  7499  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7500  	                var modeCreator = mode.createEncryptor;
  7501  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7502  	                var modeCreator = mode.createDecryptor;
  7503  
  7504  	                // Keep at least one block in the buffer for unpadding
  7505  	                this._minBufferSize = 1;
  7506  	            }
  7507  	            this._mode = modeCreator.call(mode, this, iv && iv.words);
  7508  	        },
  7509  
  7510  	        _doProcessBlock: function (words, offset) {
  7511  	            this._mode.processBlock(words, offset);
  7512  	        },
  7513  
  7514  	        _doFinalize: function () {
  7515  	            // Shortcut
  7516  	            var padding = this.cfg.padding;
  7517  
  7518  	            // Finalize
  7519  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7520  	                // Pad data
  7521  	                padding.pad(this._data, this.blockSize);
  7522  
  7523  	                // Process final blocks
  7524  	                var finalProcessedBlocks = this._process(!!'flush');
  7525  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7526  	                // Process final blocks
  7527  	                var finalProcessedBlocks = this._process(!!'flush');
  7528  
  7529  	                // Unpad data
  7530  	                padding.unpad(finalProcessedBlocks);
  7531  	            }
  7532  
  7533  	            return finalProcessedBlocks;
  7534  	        },
  7535  
  7536  	        blockSize: 128/32
  7537  	    });
  7538  
  7539  	    /**
  7540  	     * A collection of cipher parameters.
  7541  	     *
  7542  	     * @property {WordArray} ciphertext The raw ciphertext.
  7543  	     * @property {WordArray} key The key to this ciphertext.
  7544  	     * @property {WordArray} iv The IV used in the ciphering operation.
  7545  	     * @property {WordArray} salt The salt used with a key derivation function.
  7546  	     * @property {Cipher} algorithm The cipher algorithm.
  7547  	     * @property {Mode} mode The block mode used in the ciphering operation.
  7548  	     * @property {Padding} padding The padding scheme used in the ciphering operation.
  7549  	     * @property {number} blockSize The block size of the cipher.
  7550  	     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  7551  	     */
  7552  	    var CipherParams = C_lib.CipherParams = Base.extend({
  7553  	        /**
  7554  	         * Initializes a newly created cipher params object.
  7555  	         *
  7556  	         * @param {Object} cipherParams An object with any of the possible cipher parameters.
  7557  	         *
  7558  	         * @example
  7559  	         *
  7560  	         *     var cipherParams = CryptoJS.lib.CipherParams.create({
  7561  	         *         ciphertext: ciphertextWordArray,
  7562  	         *         key: keyWordArray,
  7563  	         *         iv: ivWordArray,
  7564  	         *         salt: saltWordArray,
  7565  	         *         algorithm: CryptoJS.algo.AES,
  7566  	         *         mode: CryptoJS.mode.CBC,
  7567  	         *         padding: CryptoJS.pad.PKCS7,
  7568  	         *         blockSize: 4,
  7569  	         *         formatter: CryptoJS.format.OpenSSL
  7570  	         *     });
  7571  	         */
  7572  	        init: function (cipherParams) {
  7573  	            this.mixIn(cipherParams);
  7574  	        },
  7575  
  7576  	        /**
  7577  	         * Converts this cipher params object to a string.
  7578  	         *
  7579  	         * @param {Format} formatter (Optional) The formatting strategy to use.
  7580  	         *
  7581  	         * @return {string} The stringified cipher params.
  7582  	         *
  7583  	         * @throws Error If neither the formatter nor the default formatter is set.
  7584  	         *
  7585  	         * @example
  7586  	         *
  7587  	         *     var string = cipherParams + '';
  7588  	         *     var string = cipherParams.toString();
  7589  	         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  7590  	         */
  7591  	        toString: function (formatter) {
  7592  	            return (formatter || this.formatter).stringify(this);
  7593  	        }
  7594  	    });
  7595  
  7596  	    /**
  7597  	     * Format namespace.
  7598  	     */
  7599  	    var C_format = C.format = {};
  7600  
  7601  	    /**
  7602  	     * OpenSSL formatting strategy.
  7603  	     */
  7604  	    var OpenSSLFormatter = C_format.OpenSSL = {
  7605  	        /**
  7606  	         * Converts a cipher params object to an OpenSSL-compatible string.
  7607  	         *
  7608  	         * @param {CipherParams} cipherParams The cipher params object.
  7609  	         *
  7610  	         * @return {string} The OpenSSL-compatible string.
  7611  	         *
  7612  	         * @static
  7613  	         *
  7614  	         * @example
  7615  	         *
  7616  	         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  7617  	         */
  7618  	        stringify: function (cipherParams) {
  7619  	            // Shortcuts
  7620  	            var ciphertext = cipherParams.ciphertext;
  7621  	            var salt = cipherParams.salt;
  7622  
  7623  	            // Format
  7624  	            if (salt) {
  7625  	                var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  7626  	            } else {
  7627  	                var wordArray = ciphertext;
  7628  	            }
  7629  
  7630  	            return wordArray.toString(Base64);
  7631  	        },
  7632  
  7633  	        /**
  7634  	         * Converts an OpenSSL-compatible string to a cipher params object.
  7635  	         *
  7636  	         * @param {string} openSSLStr The OpenSSL-compatible string.
  7637  	         *
  7638  	         * @return {CipherParams} The cipher params object.
  7639  	         *
  7640  	         * @static
  7641  	         *
  7642  	         * @example
  7643  	         *
  7644  	         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  7645  	         */
  7646  	        parse: function (openSSLStr) {
  7647  	            // Parse base64
  7648  	            var ciphertext = Base64.parse(openSSLStr);
  7649  
  7650  	            // Shortcut
  7651  	            var ciphertextWords = ciphertext.words;
  7652  
  7653  	            // Test for salt
  7654  	            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  7655  	                // Extract salt
  7656  	                var salt = WordArray.create(ciphertextWords.slice(2, 4));
  7657  
  7658  	                // Remove salt from ciphertext
  7659  	                ciphertextWords.splice(0, 4);
  7660  	                ciphertext.sigBytes -= 16;
  7661  	            }
  7662  
  7663  	            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  7664  	        }
  7665  	    };
  7666  
  7667  	    /**
  7668  	     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  7669  	     */
  7670  	    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  7671  	        /**
  7672  	         * Configuration options.
  7673  	         *
  7674  	         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  7675  	         */
  7676  	        cfg: Base.extend({
  7677  	            format: OpenSSLFormatter
  7678  	        }),
  7679  
  7680  	        /**
  7681  	         * Encrypts a message.
  7682  	         *
  7683  	         * @param {Cipher} cipher The cipher algorithm to use.
  7684  	         * @param {WordArray|string} message The message to encrypt.
  7685  	         * @param {WordArray} key The key.
  7686  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7687  	         *
  7688  	         * @return {CipherParams} A cipher params object.
  7689  	         *
  7690  	         * @static
  7691  	         *
  7692  	         * @example
  7693  	         *
  7694  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  7695  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  7696  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7697  	         */
  7698  	        encrypt: function (cipher, message, key, cfg) {
  7699  	            // Apply config defaults
  7700  	            cfg = this.cfg.extend(cfg);
  7701  
  7702  	            // Encrypt
  7703  	            var encryptor = cipher.createEncryptor(key, cfg);
  7704  	            var ciphertext = encryptor.finalize(message);
  7705  
  7706  	            // Shortcut
  7707  	            var cipherCfg = encryptor.cfg;
  7708  
  7709  	            // Create and return serializable cipher params
  7710  	            return CipherParams.create({
  7711  	                ciphertext: ciphertext,
  7712  	                key: key,
  7713  	                iv: cipherCfg.iv,
  7714  	                algorithm: cipher,
  7715  	                mode: cipherCfg.mode,
  7716  	                padding: cipherCfg.padding,
  7717  	                blockSize: cipher.blockSize,
  7718  	                formatter: cfg.format
  7719  	            });
  7720  	        },
  7721  
  7722  	        /**
  7723  	         * Decrypts serialized ciphertext.
  7724  	         *
  7725  	         * @param {Cipher} cipher The cipher algorithm to use.
  7726  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7727  	         * @param {WordArray} key The key.
  7728  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7729  	         *
  7730  	         * @return {WordArray} The plaintext.
  7731  	         *
  7732  	         * @static
  7733  	         *
  7734  	         * @example
  7735  	         *
  7736  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7737  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7738  	         */
  7739  	        decrypt: function (cipher, ciphertext, key, cfg) {
  7740  	            // Apply config defaults
  7741  	            cfg = this.cfg.extend(cfg);
  7742  
  7743  	            // Convert string to CipherParams
  7744  	            ciphertext = this._parse(ciphertext, cfg.format);
  7745  
  7746  	            // Decrypt
  7747  	            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  7748  
  7749  	            return plaintext;
  7750  	        },
  7751  
  7752  	        /**
  7753  	         * Converts serialized ciphertext to CipherParams,
  7754  	         * else assumed CipherParams already and returns ciphertext unchanged.
  7755  	         *
  7756  	         * @param {CipherParams|string} ciphertext The ciphertext.
  7757  	         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  7758  	         *
  7759  	         * @return {CipherParams} The unserialized ciphertext.
  7760  	         *
  7761  	         * @static
  7762  	         *
  7763  	         * @example
  7764  	         *
  7765  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  7766  	         */
  7767  	        _parse: function (ciphertext, format) {
  7768  	            if (typeof ciphertext == 'string') {
  7769  	                return format.parse(ciphertext, this);
  7770  	            } else {
  7771  	                return ciphertext;
  7772  	            }
  7773  	        }
  7774  	    });
  7775  
  7776  	    /**
  7777  	     * Key derivation function namespace.
  7778  	     */
  7779  	    var C_kdf = C.kdf = {};
  7780  
  7781  	    /**
  7782  	     * OpenSSL key derivation function.
  7783  	     */
  7784  	    var OpenSSLKdf = C_kdf.OpenSSL = {
  7785  	        /**
  7786  	         * Derives a key and IV from a password.
  7787  	         *
  7788  	         * @param {string} password The password to derive from.
  7789  	         * @param {number} keySize The size in words of the key to generate.
  7790  	         * @param {number} ivSize The size in words of the IV to generate.
  7791  	         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  7792  	         *
  7793  	         * @return {CipherParams} A cipher params object with the key, IV, and salt.
  7794  	         *
  7795  	         * @static
  7796  	         *
  7797  	         * @example
  7798  	         *
  7799  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  7800  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  7801  	         */
  7802  	        execute: function (password, keySize, ivSize, salt) {
  7803  	            // Generate random salt
  7804  	            if (!salt) {
  7805  	                salt = WordArray.random(64/8);
  7806  	            }
  7807  
  7808  	            // Derive key and IV
  7809  	            var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  7810  
  7811  	            // Separate key and IV
  7812  	            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  7813  	            key.sigBytes = keySize * 4;
  7814  
  7815  	            // Return params
  7816  	            return CipherParams.create({ key: key, iv: iv, salt: salt });
  7817  	        }
  7818  	    };
  7819  
  7820  	    /**
  7821  	     * A serializable cipher wrapper that derives the key from a password,
  7822  	     * and returns ciphertext as a serializable cipher params object.
  7823  	     */
  7824  	    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  7825  	        /**
  7826  	         * Configuration options.
  7827  	         *
  7828  	         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  7829  	         */
  7830  	        cfg: SerializableCipher.cfg.extend({
  7831  	            kdf: OpenSSLKdf
  7832  	        }),
  7833  
  7834  	        /**
  7835  	         * Encrypts a message using a password.
  7836  	         *
  7837  	         * @param {Cipher} cipher The cipher algorithm to use.
  7838  	         * @param {WordArray|string} message The message to encrypt.
  7839  	         * @param {string} password The password.
  7840  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7841  	         *
  7842  	         * @return {CipherParams} A cipher params object.
  7843  	         *
  7844  	         * @static
  7845  	         *
  7846  	         * @example
  7847  	         *
  7848  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  7849  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  7850  	         */
  7851  	        encrypt: function (cipher, message, password, cfg) {
  7852  	            // Apply config defaults
  7853  	            cfg = this.cfg.extend(cfg);
  7854  
  7855  	            // Derive key and other params
  7856  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  7857  
  7858  	            // Add IV to config
  7859  	            cfg.iv = derivedParams.iv;
  7860  
  7861  	            // Encrypt
  7862  	            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  7863  
  7864  	            // Mix in derived params
  7865  	            ciphertext.mixIn(derivedParams);
  7866  
  7867  	            return ciphertext;
  7868  	        },
  7869  
  7870  	        /**
  7871  	         * Decrypts serialized ciphertext using a password.
  7872  	         *
  7873  	         * @param {Cipher} cipher The cipher algorithm to use.
  7874  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7875  	         * @param {string} password The password.
  7876  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7877  	         *
  7878  	         * @return {WordArray} The plaintext.
  7879  	         *
  7880  	         * @static
  7881  	         *
  7882  	         * @example
  7883  	         *
  7884  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  7885  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  7886  	         */
  7887  	        decrypt: function (cipher, ciphertext, password, cfg) {
  7888  	            // Apply config defaults
  7889  	            cfg = this.cfg.extend(cfg);
  7890  
  7891  	            // Convert string to CipherParams
  7892  	            ciphertext = this._parse(ciphertext, cfg.format);
  7893  
  7894  	            // Derive key and other params
  7895  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  7896  
  7897  	            // Add IV to config
  7898  	            cfg.iv = derivedParams.iv;
  7899  
  7900  	            // Decrypt
  7901  	            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  7902  
  7903  	            return plaintext;
  7904  	        }
  7905  	    });
  7906  	}());
  7907  
  7908  
  7909  }));
  7910  },{"./core":53}],53:[function(require,module,exports){
  7911  ;(function (root, factory) {
  7912  	if (typeof exports === "object") {
  7913  		// CommonJS
  7914  		module.exports = exports = factory();
  7915  	}
  7916  	else if (typeof define === "function" && define.amd) {
  7917  		// AMD
  7918  		define([], factory);
  7919  	}
  7920  	else {
  7921  		// Global (browser)
  7922  		root.CryptoJS = factory();
  7923  	}
  7924  }(this, function () {
  7925  
  7926  	/**
  7927  	 * CryptoJS core components.
  7928  	 */
  7929  	var CryptoJS = CryptoJS || (function (Math, undefined) {
  7930  	    /*
  7931  	     * Local polyfil of Object.create
  7932  	     */
  7933  	    var create = Object.create || (function () {
  7934  	        function F() {};
  7935  
  7936  	        return function (obj) {
  7937  	            var subtype;
  7938  
  7939  	            F.prototype = obj;
  7940  
  7941  	            subtype = new F();
  7942  
  7943  	            F.prototype = null;
  7944  
  7945  	            return subtype;
  7946  	        };
  7947  	    }())
  7948  
  7949  	    /**
  7950  	     * CryptoJS namespace.
  7951  	     */
  7952  	    var C = {};
  7953  
  7954  	    /**
  7955  	     * Library namespace.
  7956  	     */
  7957  	    var C_lib = C.lib = {};
  7958  
  7959  	    /**
  7960  	     * Base object for prototypal inheritance.
  7961  	     */
  7962  	    var Base = C_lib.Base = (function () {
  7963  
  7964  
  7965  	        return {
  7966  	            /**
  7967  	             * Creates a new object that inherits from this object.
  7968  	             *
  7969  	             * @param {Object} overrides Properties to copy into the new object.
  7970  	             *
  7971  	             * @return {Object} The new object.
  7972  	             *
  7973  	             * @static
  7974  	             *
  7975  	             * @example
  7976  	             *
  7977  	             *     var MyType = CryptoJS.lib.Base.extend({
  7978  	             *         field: 'value',
  7979  	             *
  7980  	             *         method: function () {
  7981  	             *         }
  7982  	             *     });
  7983  	             */
  7984  	            extend: function (overrides) {
  7985  	                // Spawn
  7986  	                var subtype = create(this);
  7987  
  7988  	                // Augment
  7989  	                if (overrides) {
  7990  	                    subtype.mixIn(overrides);
  7991  	                }
  7992  
  7993  	                // Create default initializer
  7994  	                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  7995  	                    subtype.init = function () {
  7996  	                        subtype.$super.init.apply(this, arguments);
  7997  	                    };
  7998  	                }
  7999  
  8000  	                // Initializer's prototype is the subtype object
  8001  	                subtype.init.prototype = subtype;
  8002  
  8003  	                // Reference supertype
  8004  	                subtype.$super = this;
  8005  
  8006  	                return subtype;
  8007  	            },
  8008  
  8009  	            /**
  8010  	             * Extends this object and runs the init method.
  8011  	             * Arguments to create() will be passed to init().
  8012  	             *
  8013  	             * @return {Object} The new object.
  8014  	             *
  8015  	             * @static
  8016  	             *
  8017  	             * @example
  8018  	             *
  8019  	             *     var instance = MyType.create();
  8020  	             */
  8021  	            create: function () {
  8022  	                var instance = this.extend();
  8023  	                instance.init.apply(instance, arguments);
  8024  
  8025  	                return instance;
  8026  	            },
  8027  
  8028  	            /**
  8029  	             * Initializes a newly created object.
  8030  	             * Override this method to add some logic when your objects are created.
  8031  	             *
  8032  	             * @example
  8033  	             *
  8034  	             *     var MyType = CryptoJS.lib.Base.extend({
  8035  	             *         init: function () {
  8036  	             *             // ...
  8037  	             *         }
  8038  	             *     });
  8039  	             */
  8040  	            init: function () {
  8041  	            },
  8042  
  8043  	            /**
  8044  	             * Copies properties into this object.
  8045  	             *
  8046  	             * @param {Object} properties The properties to mix in.
  8047  	             *
  8048  	             * @example
  8049  	             *
  8050  	             *     MyType.mixIn({
  8051  	             *         field: 'value'
  8052  	             *     });
  8053  	             */
  8054  	            mixIn: function (properties) {
  8055  	                for (var propertyName in properties) {
  8056  	                    if (properties.hasOwnProperty(propertyName)) {
  8057  	                        this[propertyName] = properties[propertyName];
  8058  	                    }
  8059  	                }
  8060  
  8061  	                // IE won't copy toString using the loop above
  8062  	                if (properties.hasOwnProperty('toString')) {
  8063  	                    this.toString = properties.toString;
  8064  	                }
  8065  	            },
  8066  
  8067  	            /**
  8068  	             * Creates a copy of this object.
  8069  	             *
  8070  	             * @return {Object} The clone.
  8071  	             *
  8072  	             * @example
  8073  	             *
  8074  	             *     var clone = instance.clone();
  8075  	             */
  8076  	            clone: function () {
  8077  	                return this.init.prototype.extend(this);
  8078  	            }
  8079  	        };
  8080  	    }());
  8081  
  8082  	    /**
  8083  	     * An array of 32-bit words.
  8084  	     *
  8085  	     * @property {Array} words The array of 32-bit words.
  8086  	     * @property {number} sigBytes The number of significant bytes in this word array.
  8087  	     */
  8088  	    var WordArray = C_lib.WordArray = Base.extend({
  8089  	        /**
  8090  	         * Initializes a newly created word array.
  8091  	         *
  8092  	         * @param {Array} words (Optional) An array of 32-bit words.
  8093  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  8094  	         *
  8095  	         * @example
  8096  	         *
  8097  	         *     var wordArray = CryptoJS.lib.WordArray.create();
  8098  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  8099  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  8100  	         */
  8101  	        init: function (words, sigBytes) {
  8102  	            words = this.words = words || [];
  8103  
  8104  	            if (sigBytes != undefined) {
  8105  	                this.sigBytes = sigBytes;
  8106  	            } else {
  8107  	                this.sigBytes = words.length * 4;
  8108  	            }
  8109  	        },
  8110  
  8111  	        /**
  8112  	         * Converts this word array to a string.
  8113  	         *
  8114  	         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  8115  	         *
  8116  	         * @return {string} The stringified word array.
  8117  	         *
  8118  	         * @example
  8119  	         *
  8120  	         *     var string = wordArray + '';
  8121  	         *     var string = wordArray.toString();
  8122  	         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
  8123  	         */
  8124  	        toString: function (encoder) {
  8125  	            return (encoder || Hex).stringify(this);
  8126  	        },
  8127  
  8128  	        /**
  8129  	         * Concatenates a word array to this word array.
  8130  	         *
  8131  	         * @param {WordArray} wordArray The word array to append.
  8132  	         *
  8133  	         * @return {WordArray} This word array.
  8134  	         *
  8135  	         * @example
  8136  	         *
  8137  	         *     wordArray1.concat(wordArray2);
  8138  	         */
  8139  	        concat: function (wordArray) {
  8140  	            // Shortcuts
  8141  	            var thisWords = this.words;
  8142  	            var thatWords = wordArray.words;
  8143  	            var thisSigBytes = this.sigBytes;
  8144  	            var thatSigBytes = wordArray.sigBytes;
  8145  
  8146  	            // Clamp excess bits
  8147  	            this.clamp();
  8148  
  8149  	            // Concat
  8150  	            if (thisSigBytes % 4) {
  8151  	                // Copy one byte at a time
  8152  	                for (var i = 0; i < thatSigBytes; i++) {
  8153  	                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8154  	                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  8155  	                }
  8156  	            } else {
  8157  	                // Copy one word at a time
  8158  	                for (var i = 0; i < thatSigBytes; i += 4) {
  8159  	                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  8160  	                }
  8161  	            }
  8162  	            this.sigBytes += thatSigBytes;
  8163  
  8164  	            // Chainable
  8165  	            return this;
  8166  	        },
  8167  
  8168  	        /**
  8169  	         * Removes insignificant bits.
  8170  	         *
  8171  	         * @example
  8172  	         *
  8173  	         *     wordArray.clamp();
  8174  	         */
  8175  	        clamp: function () {
  8176  	            // Shortcuts
  8177  	            var words = this.words;
  8178  	            var sigBytes = this.sigBytes;
  8179  
  8180  	            // Clamp
  8181  	            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  8182  	            words.length = Math.ceil(sigBytes / 4);
  8183  	        },
  8184  
  8185  	        /**
  8186  	         * Creates a copy of this word array.
  8187  	         *
  8188  	         * @return {WordArray} The clone.
  8189  	         *
  8190  	         * @example
  8191  	         *
  8192  	         *     var clone = wordArray.clone();
  8193  	         */
  8194  	        clone: function () {
  8195  	            var clone = Base.clone.call(this);
  8196  	            clone.words = this.words.slice(0);
  8197  
  8198  	            return clone;
  8199  	        },
  8200  
  8201  	        /**
  8202  	         * Creates a word array filled with random bytes.
  8203  	         *
  8204  	         * @param {number} nBytes The number of random bytes to generate.
  8205  	         *
  8206  	         * @return {WordArray} The random word array.
  8207  	         *
  8208  	         * @static
  8209  	         *
  8210  	         * @example
  8211  	         *
  8212  	         *     var wordArray = CryptoJS.lib.WordArray.random(16);
  8213  	         */
  8214  	        random: function (nBytes) {
  8215  	            var words = [];
  8216  
  8217  	            var r = (function (m_w) {
  8218  	                var m_w = m_w;
  8219  	                var m_z = 0x3ade68b1;
  8220  	                var mask = 0xffffffff;
  8221  
  8222  	                return function () {
  8223  	                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  8224  	                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  8225  	                    var result = ((m_z << 0x10) + m_w) & mask;
  8226  	                    result /= 0x100000000;
  8227  	                    result += 0.5;
  8228  	                    return result * (Math.random() > .5 ? 1 : -1);
  8229  	                }
  8230  	            });
  8231  
  8232  	            for (var i = 0, rcache; i < nBytes; i += 4) {
  8233  	                var _r = r((rcache || Math.random()) * 0x100000000);
  8234  
  8235  	                rcache = _r() * 0x3ade67b7;
  8236  	                words.push((_r() * 0x100000000) | 0);
  8237  	            }
  8238  
  8239  	            return new WordArray.init(words, nBytes);
  8240  	        }
  8241  	    });
  8242  
  8243  	    /**
  8244  	     * Encoder namespace.
  8245  	     */
  8246  	    var C_enc = C.enc = {};
  8247  
  8248  	    /**
  8249  	     * Hex encoding strategy.
  8250  	     */
  8251  	    var Hex = C_enc.Hex = {
  8252  	        /**
  8253  	         * Converts a word array to a hex string.
  8254  	         *
  8255  	         * @param {WordArray} wordArray The word array.
  8256  	         *
  8257  	         * @return {string} The hex string.
  8258  	         *
  8259  	         * @static
  8260  	         *
  8261  	         * @example
  8262  	         *
  8263  	         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  8264  	         */
  8265  	        stringify: function (wordArray) {
  8266  	            // Shortcuts
  8267  	            var words = wordArray.words;
  8268  	            var sigBytes = wordArray.sigBytes;
  8269  
  8270  	            // Convert
  8271  	            var hexChars = [];
  8272  	            for (var i = 0; i < sigBytes; i++) {
  8273  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8274  	                hexChars.push((bite >>> 4).toString(16));
  8275  	                hexChars.push((bite & 0x0f).toString(16));
  8276  	            }
  8277  
  8278  	            return hexChars.join('');
  8279  	        },
  8280  
  8281  	        /**
  8282  	         * Converts a hex string to a word array.
  8283  	         *
  8284  	         * @param {string} hexStr The hex string.
  8285  	         *
  8286  	         * @return {WordArray} The word array.
  8287  	         *
  8288  	         * @static
  8289  	         *
  8290  	         * @example
  8291  	         *
  8292  	         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
  8293  	         */
  8294  	        parse: function (hexStr) {
  8295  	            // Shortcut
  8296  	            var hexStrLength = hexStr.length;
  8297  
  8298  	            // Convert
  8299  	            var words = [];
  8300  	            for (var i = 0; i < hexStrLength; i += 2) {
  8301  	                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  8302  	            }
  8303  
  8304  	            return new WordArray.init(words, hexStrLength / 2);
  8305  	        }
  8306  	    };
  8307  
  8308  	    /**
  8309  	     * Latin1 encoding strategy.
  8310  	     */
  8311  	    var Latin1 = C_enc.Latin1 = {
  8312  	        /**
  8313  	         * Converts a word array to a Latin1 string.
  8314  	         *
  8315  	         * @param {WordArray} wordArray The word array.
  8316  	         *
  8317  	         * @return {string} The Latin1 string.
  8318  	         *
  8319  	         * @static
  8320  	         *
  8321  	         * @example
  8322  	         *
  8323  	         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  8324  	         */
  8325  	        stringify: function (wordArray) {
  8326  	            // Shortcuts
  8327  	            var words = wordArray.words;
  8328  	            var sigBytes = wordArray.sigBytes;
  8329  
  8330  	            // Convert
  8331  	            var latin1Chars = [];
  8332  	            for (var i = 0; i < sigBytes; i++) {
  8333  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8334  	                latin1Chars.push(String.fromCharCode(bite));
  8335  	            }
  8336  
  8337  	            return latin1Chars.join('');
  8338  	        },
  8339  
  8340  	        /**
  8341  	         * Converts a Latin1 string to a word array.
  8342  	         *
  8343  	         * @param {string} latin1Str The Latin1 string.
  8344  	         *
  8345  	         * @return {WordArray} The word array.
  8346  	         *
  8347  	         * @static
  8348  	         *
  8349  	         * @example
  8350  	         *
  8351  	         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  8352  	         */
  8353  	        parse: function (latin1Str) {
  8354  	            // Shortcut
  8355  	            var latin1StrLength = latin1Str.length;
  8356  
  8357  	            // Convert
  8358  	            var words = [];
  8359  	            for (var i = 0; i < latin1StrLength; i++) {
  8360  	                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  8361  	            }
  8362  
  8363  	            return new WordArray.init(words, latin1StrLength);
  8364  	        }
  8365  	    };
  8366  
  8367  	    /**
  8368  	     * UTF-8 encoding strategy.
  8369  	     */
  8370  	    var Utf8 = C_enc.Utf8 = {
  8371  	        /**
  8372  	         * Converts a word array to a UTF-8 string.
  8373  	         *
  8374  	         * @param {WordArray} wordArray The word array.
  8375  	         *
  8376  	         * @return {string} The UTF-8 string.
  8377  	         *
  8378  	         * @static
  8379  	         *
  8380  	         * @example
  8381  	         *
  8382  	         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  8383  	         */
  8384  	        stringify: function (wordArray) {
  8385  	            try {
  8386  	                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  8387  	            } catch (e) {
  8388  	                throw new Error('Malformed UTF-8 data');
  8389  	            }
  8390  	        },
  8391  
  8392  	        /**
  8393  	         * Converts a UTF-8 string to a word array.
  8394  	         *
  8395  	         * @param {string} utf8Str The UTF-8 string.
  8396  	         *
  8397  	         * @return {WordArray} The word array.
  8398  	         *
  8399  	         * @static
  8400  	         *
  8401  	         * @example
  8402  	         *
  8403  	         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  8404  	         */
  8405  	        parse: function (utf8Str) {
  8406  	            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  8407  	        }
  8408  	    };
  8409  
  8410  	    /**
  8411  	     * Abstract buffered block algorithm template.
  8412  	     *
  8413  	     * The property blockSize must be implemented in a concrete subtype.
  8414  	     *
  8415  	     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  8416  	     */
  8417  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  8418  	        /**
  8419  	         * Resets this block algorithm's data buffer to its initial state.
  8420  	         *
  8421  	         * @example
  8422  	         *
  8423  	         *     bufferedBlockAlgorithm.reset();
  8424  	         */
  8425  	        reset: function () {
  8426  	            // Initial values
  8427  	            this._data = new WordArray.init();
  8428  	            this._nDataBytes = 0;
  8429  	        },
  8430  
  8431  	        /**
  8432  	         * Adds new data to this block algorithm's buffer.
  8433  	         *
  8434  	         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  8435  	         *
  8436  	         * @example
  8437  	         *
  8438  	         *     bufferedBlockAlgorithm._append('data');
  8439  	         *     bufferedBlockAlgorithm._append(wordArray);
  8440  	         */
  8441  	        _append: function (data) {
  8442  	            // Convert string to WordArray, else assume WordArray already
  8443  	            if (typeof data == 'string') {
  8444  	                data = Utf8.parse(data);
  8445  	            }
  8446  
  8447  	            // Append
  8448  	            this._data.concat(data);
  8449  	            this._nDataBytes += data.sigBytes;
  8450  	        },
  8451  
  8452  	        /**
  8453  	         * Processes available data blocks.
  8454  	         *
  8455  	         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  8456  	         *
  8457  	         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  8458  	         *
  8459  	         * @return {WordArray} The processed data.
  8460  	         *
  8461  	         * @example
  8462  	         *
  8463  	         *     var processedData = bufferedBlockAlgorithm._process();
  8464  	         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
  8465  	         */
  8466  	        _process: function (doFlush) {
  8467  	            // Shortcuts
  8468  	            var data = this._data;
  8469  	            var dataWords = data.words;
  8470  	            var dataSigBytes = data.sigBytes;
  8471  	            var blockSize = this.blockSize;
  8472  	            var blockSizeBytes = blockSize * 4;
  8473  
  8474  	            // Count blocks ready
  8475  	            var nBlocksReady = dataSigBytes / blockSizeBytes;
  8476  	            if (doFlush) {
  8477  	                // Round up to include partial blocks
  8478  	                nBlocksReady = Math.ceil(nBlocksReady);
  8479  	            } else {
  8480  	                // Round down to include only full blocks,
  8481  	                // less the number of blocks that must remain in the buffer
  8482  	                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  8483  	            }
  8484  
  8485  	            // Count words ready
  8486  	            var nWordsReady = nBlocksReady * blockSize;
  8487  
  8488  	            // Count bytes ready
  8489  	            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  8490  
  8491  	            // Process blocks
  8492  	            if (nWordsReady) {
  8493  	                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  8494  	                    // Perform concrete-algorithm logic
  8495  	                    this._doProcessBlock(dataWords, offset);
  8496  	                }
  8497  
  8498  	                // Remove processed words
  8499  	                var processedWords = dataWords.splice(0, nWordsReady);
  8500  	                data.sigBytes -= nBytesReady;
  8501  	            }
  8502  
  8503  	            // Return processed words
  8504  	            return new WordArray.init(processedWords, nBytesReady);
  8505  	        },
  8506  
  8507  	        /**
  8508  	         * Creates a copy of this object.
  8509  	         *
  8510  	         * @return {Object} The clone.
  8511  	         *
  8512  	         * @example
  8513  	         *
  8514  	         *     var clone = bufferedBlockAlgorithm.clone();
  8515  	         */
  8516  	        clone: function () {
  8517  	            var clone = Base.clone.call(this);
  8518  	            clone._data = this._data.clone();
  8519  
  8520  	            return clone;
  8521  	        },
  8522  
  8523  	        _minBufferSize: 0
  8524  	    });
  8525  
  8526  	    /**
  8527  	     * Abstract hasher template.
  8528  	     *
  8529  	     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  8530  	     */
  8531  	    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  8532  	        /**
  8533  	         * Configuration options.
  8534  	         */
  8535  	        cfg: Base.extend(),
  8536  
  8537  	        /**
  8538  	         * Initializes a newly created hasher.
  8539  	         *
  8540  	         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  8541  	         *
  8542  	         * @example
  8543  	         *
  8544  	         *     var hasher = CryptoJS.algo.SHA256.create();
  8545  	         */
  8546  	        init: function (cfg) {
  8547  	            // Apply config defaults
  8548  	            this.cfg = this.cfg.extend(cfg);
  8549  
  8550  	            // Set initial values
  8551  	            this.reset();
  8552  	        },
  8553  
  8554  	        /**
  8555  	         * Resets this hasher to its initial state.
  8556  	         *
  8557  	         * @example
  8558  	         *
  8559  	         *     hasher.reset();
  8560  	         */
  8561  	        reset: function () {
  8562  	            // Reset data buffer
  8563  	            BufferedBlockAlgorithm.reset.call(this);
  8564  
  8565  	            // Perform concrete-hasher logic
  8566  	            this._doReset();
  8567  	        },
  8568  
  8569  	        /**
  8570  	         * Updates this hasher with a message.
  8571  	         *
  8572  	         * @param {WordArray|string} messageUpdate The message to append.
  8573  	         *
  8574  	         * @return {Hasher} This hasher.
  8575  	         *
  8576  	         * @example
  8577  	         *
  8578  	         *     hasher.update('message');
  8579  	         *     hasher.update(wordArray);
  8580  	         */
  8581  	        update: function (messageUpdate) {
  8582  	            // Append
  8583  	            this._append(messageUpdate);
  8584  
  8585  	            // Update the hash
  8586  	            this._process();
  8587  
  8588  	            // Chainable
  8589  	            return this;
  8590  	        },
  8591  
  8592  	        /**
  8593  	         * Finalizes the hash computation.
  8594  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  8595  	         *
  8596  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8597  	         *
  8598  	         * @return {WordArray} The hash.
  8599  	         *
  8600  	         * @example
  8601  	         *
  8602  	         *     var hash = hasher.finalize();
  8603  	         *     var hash = hasher.finalize('message');
  8604  	         *     var hash = hasher.finalize(wordArray);
  8605  	         */
  8606  	        finalize: function (messageUpdate) {
  8607  	            // Final message update
  8608  	            if (messageUpdate) {
  8609  	                this._append(messageUpdate);
  8610  	            }
  8611  
  8612  	            // Perform concrete-hasher logic
  8613  	            var hash = this._doFinalize();
  8614  
  8615  	            return hash;
  8616  	        },
  8617  
  8618  	        blockSize: 512/32,
  8619  
  8620  	        /**
  8621  	         * Creates a shortcut function to a hasher's object interface.
  8622  	         *
  8623  	         * @param {Hasher} hasher The hasher to create a helper for.
  8624  	         *
  8625  	         * @return {Function} The shortcut function.
  8626  	         *
  8627  	         * @static
  8628  	         *
  8629  	         * @example
  8630  	         *
  8631  	         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  8632  	         */
  8633  	        _createHelper: function (hasher) {
  8634  	            return function (message, cfg) {
  8635  	                return new hasher.init(cfg).finalize(message);
  8636  	            };
  8637  	        },
  8638  
  8639  	        /**
  8640  	         * Creates a shortcut function to the HMAC's object interface.
  8641  	         *
  8642  	         * @param {Hasher} hasher The hasher to use in this HMAC helper.
  8643  	         *
  8644  	         * @return {Function} The shortcut function.
  8645  	         *
  8646  	         * @static
  8647  	         *
  8648  	         * @example
  8649  	         *
  8650  	         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  8651  	         */
  8652  	        _createHmacHelper: function (hasher) {
  8653  	            return function (message, key) {
  8654  	                return new C_algo.HMAC.init(hasher, key).finalize(message);
  8655  	            };
  8656  	        }
  8657  	    });
  8658  
  8659  	    /**
  8660  	     * Algorithm namespace.
  8661  	     */
  8662  	    var C_algo = C.algo = {};
  8663  
  8664  	    return C;
  8665  	}(Math));
  8666  
  8667  
  8668  	return CryptoJS;
  8669  
  8670  }));
  8671  },{}],54:[function(require,module,exports){
  8672  ;(function (root, factory) {
  8673  	if (typeof exports === "object") {
  8674  		// CommonJS
  8675  		module.exports = exports = factory(require("./core"));
  8676  	}
  8677  	else if (typeof define === "function" && define.amd) {
  8678  		// AMD
  8679  		define(["./core"], factory);
  8680  	}
  8681  	else {
  8682  		// Global (browser)
  8683  		factory(root.CryptoJS);
  8684  	}
  8685  }(this, function (CryptoJS) {
  8686  
  8687  	(function () {
  8688  	    // Shortcuts
  8689  	    var C = CryptoJS;
  8690  	    var C_lib = C.lib;
  8691  	    var WordArray = C_lib.WordArray;
  8692  	    var C_enc = C.enc;
  8693  
  8694  	    /**
  8695  	     * Base64 encoding strategy.
  8696  	     */
  8697  	    var Base64 = C_enc.Base64 = {
  8698  	        /**
  8699  	         * Converts a word array to a Base64 string.
  8700  	         *
  8701  	         * @param {WordArray} wordArray The word array.
  8702  	         *
  8703  	         * @return {string} The Base64 string.
  8704  	         *
  8705  	         * @static
  8706  	         *
  8707  	         * @example
  8708  	         *
  8709  	         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  8710  	         */
  8711  	        stringify: function (wordArray) {
  8712  	            // Shortcuts
  8713  	            var words = wordArray.words;
  8714  	            var sigBytes = wordArray.sigBytes;
  8715  	            var map = this._map;
  8716  
  8717  	            // Clamp excess bits
  8718  	            wordArray.clamp();
  8719  
  8720  	            // Convert
  8721  	            var base64Chars = [];
  8722  	            for (var i = 0; i < sigBytes; i += 3) {
  8723  	                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
  8724  	                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  8725  	                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  8726  
  8727  	                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  8728  
  8729  	                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  8730  	                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  8731  	                }
  8732  	            }
  8733  
  8734  	            // Add padding
  8735  	            var paddingChar = map.charAt(64);
  8736  	            if (paddingChar) {
  8737  	                while (base64Chars.length % 4) {
  8738  	                    base64Chars.push(paddingChar);
  8739  	                }
  8740  	            }
  8741  
  8742  	            return base64Chars.join('');
  8743  	        },
  8744  
  8745  	        /**
  8746  	         * Converts a Base64 string to a word array.
  8747  	         *
  8748  	         * @param {string} base64Str The Base64 string.
  8749  	         *
  8750  	         * @return {WordArray} The word array.
  8751  	         *
  8752  	         * @static
  8753  	         *
  8754  	         * @example
  8755  	         *
  8756  	         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
  8757  	         */
  8758  	        parse: function (base64Str) {
  8759  	            // Shortcuts
  8760  	            var base64StrLength = base64Str.length;
  8761  	            var map = this._map;
  8762  	            var reverseMap = this._reverseMap;
  8763  
  8764  	            if (!reverseMap) {
  8765  	                    reverseMap = this._reverseMap = [];
  8766  	                    for (var j = 0; j < map.length; j++) {
  8767  	                        reverseMap[map.charCodeAt(j)] = j;
  8768  	                    }
  8769  	            }
  8770  
  8771  	            // Ignore padding
  8772  	            var paddingChar = map.charAt(64);
  8773  	            if (paddingChar) {
  8774  	                var paddingIndex = base64Str.indexOf(paddingChar);
  8775  	                if (paddingIndex !== -1) {
  8776  	                    base64StrLength = paddingIndex;
  8777  	                }
  8778  	            }
  8779  
  8780  	            // Convert
  8781  	            return parseLoop(base64Str, base64StrLength, reverseMap);
  8782  
  8783  	        },
  8784  
  8785  	        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  8786  	    };
  8787  
  8788  	    function parseLoop(base64Str, base64StrLength, reverseMap) {
  8789  	      var words = [];
  8790  	      var nBytes = 0;
  8791  	      for (var i = 0; i < base64StrLength; i++) {
  8792  	          if (i % 4) {
  8793  	              var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  8794  	              var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  8795  	              words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  8796  	              nBytes++;
  8797  	          }
  8798  	      }
  8799  	      return WordArray.create(words, nBytes);
  8800  	    }
  8801  	}());
  8802  
  8803  
  8804  	return CryptoJS.enc.Base64;
  8805  
  8806  }));
  8807  },{"./core":53}],55:[function(require,module,exports){
  8808  ;(function (root, factory) {
  8809  	if (typeof exports === "object") {
  8810  		// CommonJS
  8811  		module.exports = exports = factory(require("./core"));
  8812  	}
  8813  	else if (typeof define === "function" && define.amd) {
  8814  		// AMD
  8815  		define(["./core"], factory);
  8816  	}
  8817  	else {
  8818  		// Global (browser)
  8819  		factory(root.CryptoJS);
  8820  	}
  8821  }(this, function (CryptoJS) {
  8822  
  8823  	(function () {
  8824  	    // Shortcuts
  8825  	    var C = CryptoJS;
  8826  	    var C_lib = C.lib;
  8827  	    var WordArray = C_lib.WordArray;
  8828  	    var C_enc = C.enc;
  8829  
  8830  	    /**
  8831  	     * UTF-16 BE encoding strategy.
  8832  	     */
  8833  	    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  8834  	        /**
  8835  	         * Converts a word array to a UTF-16 BE string.
  8836  	         *
  8837  	         * @param {WordArray} wordArray The word array.
  8838  	         *
  8839  	         * @return {string} The UTF-16 BE string.
  8840  	         *
  8841  	         * @static
  8842  	         *
  8843  	         * @example
  8844  	         *
  8845  	         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  8846  	         */
  8847  	        stringify: function (wordArray) {
  8848  	            // Shortcuts
  8849  	            var words = wordArray.words;
  8850  	            var sigBytes = wordArray.sigBytes;
  8851  
  8852  	            // Convert
  8853  	            var utf16Chars = [];
  8854  	            for (var i = 0; i < sigBytes; i += 2) {
  8855  	                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  8856  	                utf16Chars.push(String.fromCharCode(codePoint));
  8857  	            }
  8858  
  8859  	            return utf16Chars.join('');
  8860  	        },
  8861  
  8862  	        /**
  8863  	         * Converts a UTF-16 BE string to a word array.
  8864  	         *
  8865  	         * @param {string} utf16Str The UTF-16 BE string.
  8866  	         *
  8867  	         * @return {WordArray} The word array.
  8868  	         *
  8869  	         * @static
  8870  	         *
  8871  	         * @example
  8872  	         *
  8873  	         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  8874  	         */
  8875  	        parse: function (utf16Str) {
  8876  	            // Shortcut
  8877  	            var utf16StrLength = utf16Str.length;
  8878  
  8879  	            // Convert
  8880  	            var words = [];
  8881  	            for (var i = 0; i < utf16StrLength; i++) {
  8882  	                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  8883  	            }
  8884  
  8885  	            return WordArray.create(words, utf16StrLength * 2);
  8886  	        }
  8887  	    };
  8888  
  8889  	    /**
  8890  	     * UTF-16 LE encoding strategy.
  8891  	     */
  8892  	    C_enc.Utf16LE = {
  8893  	        /**
  8894  	         * Converts a word array to a UTF-16 LE string.
  8895  	         *
  8896  	         * @param {WordArray} wordArray The word array.
  8897  	         *
  8898  	         * @return {string} The UTF-16 LE string.
  8899  	         *
  8900  	         * @static
  8901  	         *
  8902  	         * @example
  8903  	         *
  8904  	         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  8905  	         */
  8906  	        stringify: function (wordArray) {
  8907  	            // Shortcuts
  8908  	            var words = wordArray.words;
  8909  	            var sigBytes = wordArray.sigBytes;
  8910  
  8911  	            // Convert
  8912  	            var utf16Chars = [];
  8913  	            for (var i = 0; i < sigBytes; i += 2) {
  8914  	                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  8915  	                utf16Chars.push(String.fromCharCode(codePoint));
  8916  	            }
  8917  
  8918  	            return utf16Chars.join('');
  8919  	        },
  8920  
  8921  	        /**
  8922  	         * Converts a UTF-16 LE string to a word array.
  8923  	         *
  8924  	         * @param {string} utf16Str The UTF-16 LE string.
  8925  	         *
  8926  	         * @return {WordArray} The word array.
  8927  	         *
  8928  	         * @static
  8929  	         *
  8930  	         * @example
  8931  	         *
  8932  	         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  8933  	         */
  8934  	        parse: function (utf16Str) {
  8935  	            // Shortcut
  8936  	            var utf16StrLength = utf16Str.length;
  8937  
  8938  	            // Convert
  8939  	            var words = [];
  8940  	            for (var i = 0; i < utf16StrLength; i++) {
  8941  	                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  8942  	            }
  8943  
  8944  	            return WordArray.create(words, utf16StrLength * 2);
  8945  	        }
  8946  	    };
  8947  
  8948  	    function swapEndian(word) {
  8949  	        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  8950  	    }
  8951  	}());
  8952  
  8953  
  8954  	return CryptoJS.enc.Utf16;
  8955  
  8956  }));
  8957  },{"./core":53}],56:[function(require,module,exports){
  8958  ;(function (root, factory, undef) {
  8959  	if (typeof exports === "object") {
  8960  		// CommonJS
  8961  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8962  	}
  8963  	else if (typeof define === "function" && define.amd) {
  8964  		// AMD
  8965  		define(["./core", "./sha1", "./hmac"], factory);
  8966  	}
  8967  	else {
  8968  		// Global (browser)
  8969  		factory(root.CryptoJS);
  8970  	}
  8971  }(this, function (CryptoJS) {
  8972  
  8973  	(function () {
  8974  	    // Shortcuts
  8975  	    var C = CryptoJS;
  8976  	    var C_lib = C.lib;
  8977  	    var Base = C_lib.Base;
  8978  	    var WordArray = C_lib.WordArray;
  8979  	    var C_algo = C.algo;
  8980  	    var MD5 = C_algo.MD5;
  8981  
  8982  	    /**
  8983  	     * This key derivation function is meant to conform with EVP_BytesToKey.
  8984  	     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  8985  	     */
  8986  	    var EvpKDF = C_algo.EvpKDF = Base.extend({
  8987  	        /**
  8988  	         * Configuration options.
  8989  	         *
  8990  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8991  	         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  8992  	         * @property {number} iterations The number of iterations to perform. Default: 1
  8993  	         */
  8994  	        cfg: Base.extend({
  8995  	            keySize: 128/32,
  8996  	            hasher: MD5,
  8997  	            iterations: 1
  8998  	        }),
  8999  
  9000  	        /**
  9001  	         * Initializes a newly created key derivation function.
  9002  	         *
  9003  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  9004  	         *
  9005  	         * @example
  9006  	         *
  9007  	         *     var kdf = CryptoJS.algo.EvpKDF.create();
  9008  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  9009  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  9010  	         */
  9011  	        init: function (cfg) {
  9012  	            this.cfg = this.cfg.extend(cfg);
  9013  	        },
  9014  
  9015  	        /**
  9016  	         * Derives a key from a password.
  9017  	         *
  9018  	         * @param {WordArray|string} password The password.
  9019  	         * @param {WordArray|string} salt A salt.
  9020  	         *
  9021  	         * @return {WordArray} The derived key.
  9022  	         *
  9023  	         * @example
  9024  	         *
  9025  	         *     var key = kdf.compute(password, salt);
  9026  	         */
  9027  	        compute: function (password, salt) {
  9028  	            // Shortcut
  9029  	            var cfg = this.cfg;
  9030  
  9031  	            // Init hasher
  9032  	            var hasher = cfg.hasher.create();
  9033  
  9034  	            // Initial values
  9035  	            var derivedKey = WordArray.create();
  9036  
  9037  	            // Shortcuts
  9038  	            var derivedKeyWords = derivedKey.words;
  9039  	            var keySize = cfg.keySize;
  9040  	            var iterations = cfg.iterations;
  9041  
  9042  	            // Generate key
  9043  	            while (derivedKeyWords.length < keySize) {
  9044  	                if (block) {
  9045  	                    hasher.update(block);
  9046  	                }
  9047  	                var block = hasher.update(password).finalize(salt);
  9048  	                hasher.reset();
  9049  
  9050  	                // Iterations
  9051  	                for (var i = 1; i < iterations; i++) {
  9052  	                    block = hasher.finalize(block);
  9053  	                    hasher.reset();
  9054  	                }
  9055  
  9056  	                derivedKey.concat(block);
  9057  	            }
  9058  	            derivedKey.sigBytes = keySize * 4;
  9059  
  9060  	            return derivedKey;
  9061  	        }
  9062  	    });
  9063  
  9064  	    /**
  9065  	     * Derives a key from a password.
  9066  	     *
  9067  	     * @param {WordArray|string} password The password.
  9068  	     * @param {WordArray|string} salt A salt.
  9069  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
  9070  	     *
  9071  	     * @return {WordArray} The derived key.
  9072  	     *
  9073  	     * @static
  9074  	     *
  9075  	     * @example
  9076  	     *
  9077  	     *     var key = CryptoJS.EvpKDF(password, salt);
  9078  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  9079  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  9080  	     */
  9081  	    C.EvpKDF = function (password, salt, cfg) {
  9082  	        return EvpKDF.create(cfg).compute(password, salt);
  9083  	    };
  9084  	}());
  9085  
  9086  
  9087  	return CryptoJS.EvpKDF;
  9088  
  9089  }));
  9090  },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
  9091  ;(function (root, factory, undef) {
  9092  	if (typeof exports === "object") {
  9093  		// CommonJS
  9094  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9095  	}
  9096  	else if (typeof define === "function" && define.amd) {
  9097  		// AMD
  9098  		define(["./core", "./cipher-core"], factory);
  9099  	}
  9100  	else {
  9101  		// Global (browser)
  9102  		factory(root.CryptoJS);
  9103  	}
  9104  }(this, function (CryptoJS) {
  9105  
  9106  	(function (undefined) {
  9107  	    // Shortcuts
  9108  	    var C = CryptoJS;
  9109  	    var C_lib = C.lib;
  9110  	    var CipherParams = C_lib.CipherParams;
  9111  	    var C_enc = C.enc;
  9112  	    var Hex = C_enc.Hex;
  9113  	    var C_format = C.format;
  9114  
  9115  	    var HexFormatter = C_format.Hex = {
  9116  	        /**
  9117  	         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  9118  	         *
  9119  	         * @param {CipherParams} cipherParams The cipher params object.
  9120  	         *
  9121  	         * @return {string} The hexadecimally encoded string.
  9122  	         *
  9123  	         * @static
  9124  	         *
  9125  	         * @example
  9126  	         *
  9127  	         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  9128  	         */
  9129  	        stringify: function (cipherParams) {
  9130  	            return cipherParams.ciphertext.toString(Hex);
  9131  	        },
  9132  
  9133  	        /**
  9134  	         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  9135  	         *
  9136  	         * @param {string} input The hexadecimally encoded string.
  9137  	         *
  9138  	         * @return {CipherParams} The cipher params object.
  9139  	         *
  9140  	         * @static
  9141  	         *
  9142  	         * @example
  9143  	         *
  9144  	         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  9145  	         */
  9146  	        parse: function (input) {
  9147  	            var ciphertext = Hex.parse(input);
  9148  	            return CipherParams.create({ ciphertext: ciphertext });
  9149  	        }
  9150  	    };
  9151  	}());
  9152  
  9153  
  9154  	return CryptoJS.format.Hex;
  9155  
  9156  }));
  9157  },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
  9158  ;(function (root, factory) {
  9159  	if (typeof exports === "object") {
  9160  		// CommonJS
  9161  		module.exports = exports = factory(require("./core"));
  9162  	}
  9163  	else if (typeof define === "function" && define.amd) {
  9164  		// AMD
  9165  		define(["./core"], factory);
  9166  	}
  9167  	else {
  9168  		// Global (browser)
  9169  		factory(root.CryptoJS);
  9170  	}
  9171  }(this, function (CryptoJS) {
  9172  
  9173  	(function () {
  9174  	    // Shortcuts
  9175  	    var C = CryptoJS;
  9176  	    var C_lib = C.lib;
  9177  	    var Base = C_lib.Base;
  9178  	    var C_enc = C.enc;
  9179  	    var Utf8 = C_enc.Utf8;
  9180  	    var C_algo = C.algo;
  9181  
  9182  	    /**
  9183  	     * HMAC algorithm.
  9184  	     */
  9185  	    var HMAC = C_algo.HMAC = Base.extend({
  9186  	        /**
  9187  	         * Initializes a newly created HMAC.
  9188  	         *
  9189  	         * @param {Hasher} hasher The hash algorithm to use.
  9190  	         * @param {WordArray|string} key The secret key.
  9191  	         *
  9192  	         * @example
  9193  	         *
  9194  	         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  9195  	         */
  9196  	        init: function (hasher, key) {
  9197  	            // Init hasher
  9198  	            hasher = this._hasher = new hasher.init();
  9199  
  9200  	            // Convert string to WordArray, else assume WordArray already
  9201  	            if (typeof key == 'string') {
  9202  	                key = Utf8.parse(key);
  9203  	            }
  9204  
  9205  	            // Shortcuts
  9206  	            var hasherBlockSize = hasher.blockSize;
  9207  	            var hasherBlockSizeBytes = hasherBlockSize * 4;
  9208  
  9209  	            // Allow arbitrary length keys
  9210  	            if (key.sigBytes > hasherBlockSizeBytes) {
  9211  	                key = hasher.finalize(key);
  9212  	            }
  9213  
  9214  	            // Clamp excess bits
  9215  	            key.clamp();
  9216  
  9217  	            // Clone key for inner and outer pads
  9218  	            var oKey = this._oKey = key.clone();
  9219  	            var iKey = this._iKey = key.clone();
  9220  
  9221  	            // Shortcuts
  9222  	            var oKeyWords = oKey.words;
  9223  	            var iKeyWords = iKey.words;
  9224  
  9225  	            // XOR keys with pad constants
  9226  	            for (var i = 0; i < hasherBlockSize; i++) {
  9227  	                oKeyWords[i] ^= 0x5c5c5c5c;
  9228  	                iKeyWords[i] ^= 0x36363636;
  9229  	            }
  9230  	            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  9231  
  9232  	            // Set initial values
  9233  	            this.reset();
  9234  	        },
  9235  
  9236  	        /**
  9237  	         * Resets this HMAC to its initial state.
  9238  	         *
  9239  	         * @example
  9240  	         *
  9241  	         *     hmacHasher.reset();
  9242  	         */
  9243  	        reset: function () {
  9244  	            // Shortcut
  9245  	            var hasher = this._hasher;
  9246  
  9247  	            // Reset
  9248  	            hasher.reset();
  9249  	            hasher.update(this._iKey);
  9250  	        },
  9251  
  9252  	        /**
  9253  	         * Updates this HMAC with a message.
  9254  	         *
  9255  	         * @param {WordArray|string} messageUpdate The message to append.
  9256  	         *
  9257  	         * @return {HMAC} This HMAC instance.
  9258  	         *
  9259  	         * @example
  9260  	         *
  9261  	         *     hmacHasher.update('message');
  9262  	         *     hmacHasher.update(wordArray);
  9263  	         */
  9264  	        update: function (messageUpdate) {
  9265  	            this._hasher.update(messageUpdate);
  9266  
  9267  	            // Chainable
  9268  	            return this;
  9269  	        },
  9270  
  9271  	        /**
  9272  	         * Finalizes the HMAC computation.
  9273  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  9274  	         *
  9275  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  9276  	         *
  9277  	         * @return {WordArray} The HMAC.
  9278  	         *
  9279  	         * @example
  9280  	         *
  9281  	         *     var hmac = hmacHasher.finalize();
  9282  	         *     var hmac = hmacHasher.finalize('message');
  9283  	         *     var hmac = hmacHasher.finalize(wordArray);
  9284  	         */
  9285  	        finalize: function (messageUpdate) {
  9286  	            // Shortcut
  9287  	            var hasher = this._hasher;
  9288  
  9289  	            // Compute HMAC
  9290  	            var innerHash = hasher.finalize(messageUpdate);
  9291  	            hasher.reset();
  9292  	            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  9293  
  9294  	            return hmac;
  9295  	        }
  9296  	    });
  9297  	}());
  9298  
  9299  
  9300  }));
  9301  },{"./core":53}],59:[function(require,module,exports){
  9302  ;(function (root, factory, undef) {
  9303  	if (typeof exports === "object") {
  9304  		// CommonJS
  9305  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy"));
  9306  	}
  9307  	else if (typeof define === "function" && define.amd) {
  9308  		// AMD
  9309  		define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
  9310  	}
  9311  	else {
  9312  		// Global (browser)
  9313  		root.CryptoJS = factory(root.CryptoJS);
  9314  	}
  9315  }(this, function (CryptoJS) {
  9316  
  9317  	return CryptoJS;
  9318  
  9319  }));
  9320  },{"./aes":51,"./cipher-core":52,"./core":53,"./enc-base64":54,"./enc-utf16":55,"./evpkdf":56,"./format-hex":57,"./hmac":58,"./lib-typedarrays":60,"./md5":61,"./mode-cfb":62,"./mode-ctr":64,"./mode-ctr-gladman":63,"./mode-ecb":65,"./mode-ofb":66,"./pad-ansix923":67,"./pad-iso10126":68,"./pad-iso97971":69,"./pad-nopadding":70,"./pad-zeropadding":71,"./pbkdf2":72,"./rabbit":74,"./rabbit-legacy":73,"./rc4":75,"./ripemd160":76,"./sha1":77,"./sha224":78,"./sha256":79,"./sha3":80,"./sha384":81,"./sha512":82,"./tripledes":83,"./x64-core":84}],60:[function(require,module,exports){
  9321  ;(function (root, factory) {
  9322  	if (typeof exports === "object") {
  9323  		// CommonJS
  9324  		module.exports = exports = factory(require("./core"));
  9325  	}
  9326  	else if (typeof define === "function" && define.amd) {
  9327  		// AMD
  9328  		define(["./core"], factory);
  9329  	}
  9330  	else {
  9331  		// Global (browser)
  9332  		factory(root.CryptoJS);
  9333  	}
  9334  }(this, function (CryptoJS) {
  9335  
  9336  	(function () {
  9337  	    // Check if typed arrays are supported
  9338  	    if (typeof ArrayBuffer != 'function') {
  9339  	        return;
  9340  	    }
  9341  
  9342  	    // Shortcuts
  9343  	    var C = CryptoJS;
  9344  	    var C_lib = C.lib;
  9345  	    var WordArray = C_lib.WordArray;
  9346  
  9347  	    // Reference original init
  9348  	    var superInit = WordArray.init;
  9349  
  9350  	    // Augment WordArray.init to handle typed arrays
  9351  	    var subInit = WordArray.init = function (typedArray) {
  9352  	        // Convert buffers to uint8
  9353  	        if (typedArray instanceof ArrayBuffer) {
  9354  	            typedArray = new Uint8Array(typedArray);
  9355  	        }
  9356  
  9357  	        // Convert other array views to uint8
  9358  	        if (
  9359  	            typedArray instanceof Int8Array ||
  9360  	            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  9361  	            typedArray instanceof Int16Array ||
  9362  	            typedArray instanceof Uint16Array ||
  9363  	            typedArray instanceof Int32Array ||
  9364  	            typedArray instanceof Uint32Array ||
  9365  	            typedArray instanceof Float32Array ||
  9366  	            typedArray instanceof Float64Array
  9367  	        ) {
  9368  	            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  9369  	        }
  9370  
  9371  	        // Handle Uint8Array
  9372  	        if (typedArray instanceof Uint8Array) {
  9373  	            // Shortcut
  9374  	            var typedArrayByteLength = typedArray.byteLength;
  9375  
  9376  	            // Extract bytes
  9377  	            var words = [];
  9378  	            for (var i = 0; i < typedArrayByteLength; i++) {
  9379  	                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  9380  	            }
  9381  
  9382  	            // Initialize this word array
  9383  	            superInit.call(this, words, typedArrayByteLength);
  9384  	        } else {
  9385  	            // Else call normal init
  9386  	            superInit.apply(this, arguments);
  9387  	        }
  9388  	    };
  9389  
  9390  	    subInit.prototype = WordArray;
  9391  	}());
  9392  
  9393  
  9394  	return CryptoJS.lib.WordArray;
  9395  
  9396  }));
  9397  },{"./core":53}],61:[function(require,module,exports){
  9398  ;(function (root, factory) {
  9399  	if (typeof exports === "object") {
  9400  		// CommonJS
  9401  		module.exports = exports = factory(require("./core"));
  9402  	}
  9403  	else if (typeof define === "function" && define.amd) {
  9404  		// AMD
  9405  		define(["./core"], factory);
  9406  	}
  9407  	else {
  9408  		// Global (browser)
  9409  		factory(root.CryptoJS);
  9410  	}
  9411  }(this, function (CryptoJS) {
  9412  
  9413  	(function (Math) {
  9414  	    // Shortcuts
  9415  	    var C = CryptoJS;
  9416  	    var C_lib = C.lib;
  9417  	    var WordArray = C_lib.WordArray;
  9418  	    var Hasher = C_lib.Hasher;
  9419  	    var C_algo = C.algo;
  9420  
  9421  	    // Constants table
  9422  	    var T = [];
  9423  
  9424  	    // Compute constants
  9425  	    (function () {
  9426  	        for (var i = 0; i < 64; i++) {
  9427  	            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  9428  	        }
  9429  	    }());
  9430  
  9431  	    /**
  9432  	     * MD5 hash algorithm.
  9433  	     */
  9434  	    var MD5 = C_algo.MD5 = Hasher.extend({
  9435  	        _doReset: function () {
  9436  	            this._hash = new WordArray.init([
  9437  	                0x67452301, 0xefcdab89,
  9438  	                0x98badcfe, 0x10325476
  9439  	            ]);
  9440  	        },
  9441  
  9442  	        _doProcessBlock: function (M, offset) {
  9443  	            // Swap endian
  9444  	            for (var i = 0; i < 16; i++) {
  9445  	                // Shortcuts
  9446  	                var offset_i = offset + i;
  9447  	                var M_offset_i = M[offset_i];
  9448  
  9449  	                M[offset_i] = (
  9450  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9451  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
  9452  	                );
  9453  	            }
  9454  
  9455  	            // Shortcuts
  9456  	            var H = this._hash.words;
  9457  
  9458  	            var M_offset_0  = M[offset + 0];
  9459  	            var M_offset_1  = M[offset + 1];
  9460  	            var M_offset_2  = M[offset + 2];
  9461  	            var M_offset_3  = M[offset + 3];
  9462  	            var M_offset_4  = M[offset + 4];
  9463  	            var M_offset_5  = M[offset + 5];
  9464  	            var M_offset_6  = M[offset + 6];
  9465  	            var M_offset_7  = M[offset + 7];
  9466  	            var M_offset_8  = M[offset + 8];
  9467  	            var M_offset_9  = M[offset + 9];
  9468  	            var M_offset_10 = M[offset + 10];
  9469  	            var M_offset_11 = M[offset + 11];
  9470  	            var M_offset_12 = M[offset + 12];
  9471  	            var M_offset_13 = M[offset + 13];
  9472  	            var M_offset_14 = M[offset + 14];
  9473  	            var M_offset_15 = M[offset + 15];
  9474  
  9475  	            // Working varialbes
  9476  	            var a = H[0];
  9477  	            var b = H[1];
  9478  	            var c = H[2];
  9479  	            var d = H[3];
  9480  
  9481  	            // Computation
  9482  	            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
  9483  	            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
  9484  	            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
  9485  	            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
  9486  	            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
  9487  	            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
  9488  	            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
  9489  	            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
  9490  	            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
  9491  	            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
  9492  	            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  9493  	            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  9494  	            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
  9495  	            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  9496  	            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  9497  	            b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  9498  
  9499  	            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
  9500  	            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
  9501  	            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  9502  	            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
  9503  	            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
  9504  	            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
  9505  	            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  9506  	            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
  9507  	            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
  9508  	            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
  9509  	            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
  9510  	            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
  9511  	            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
  9512  	            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
  9513  	            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
  9514  	            b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  9515  
  9516  	            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
  9517  	            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
  9518  	            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  9519  	            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  9520  	            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
  9521  	            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
  9522  	            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
  9523  	            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  9524  	            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
  9525  	            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
  9526  	            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
  9527  	            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
  9528  	            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
  9529  	            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  9530  	            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  9531  	            b = HH(b, c, d, a, M_offset_2,  23, T[47]);
  9532  
  9533  	            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
  9534  	            d = II(d, a, b, c, M_offset_7,  10, T[49]);
  9535  	            c = II(c, d, a, b, M_offset_14, 15, T[50]);
  9536  	            b = II(b, c, d, a, M_offset_5,  21, T[51]);
  9537  	            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
  9538  	            d = II(d, a, b, c, M_offset_3,  10, T[53]);
  9539  	            c = II(c, d, a, b, M_offset_10, 15, T[54]);
  9540  	            b = II(b, c, d, a, M_offset_1,  21, T[55]);
  9541  	            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
  9542  	            d = II(d, a, b, c, M_offset_15, 10, T[57]);
  9543  	            c = II(c, d, a, b, M_offset_6,  15, T[58]);
  9544  	            b = II(b, c, d, a, M_offset_13, 21, T[59]);
  9545  	            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
  9546  	            d = II(d, a, b, c, M_offset_11, 10, T[61]);
  9547  	            c = II(c, d, a, b, M_offset_2,  15, T[62]);
  9548  	            b = II(b, c, d, a, M_offset_9,  21, T[63]);
  9549  
  9550  	            // Intermediate hash value
  9551  	            H[0] = (H[0] + a) | 0;
  9552  	            H[1] = (H[1] + b) | 0;
  9553  	            H[2] = (H[2] + c) | 0;
  9554  	            H[3] = (H[3] + d) | 0;
  9555  	        },
  9556  
  9557  	        _doFinalize: function () {
  9558  	            // Shortcuts
  9559  	            var data = this._data;
  9560  	            var dataWords = data.words;
  9561  
  9562  	            var nBitsTotal = this._nDataBytes * 8;
  9563  	            var nBitsLeft = data.sigBytes * 8;
  9564  
  9565  	            // Add padding
  9566  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9567  
  9568  	            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  9569  	            var nBitsTotalL = nBitsTotal;
  9570  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  9571  	                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  9572  	                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
  9573  	            );
  9574  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9575  	                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  9576  	                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
  9577  	            );
  9578  
  9579  	            data.sigBytes = (dataWords.length + 1) * 4;
  9580  
  9581  	            // Hash final blocks
  9582  	            this._process();
  9583  
  9584  	            // Shortcuts
  9585  	            var hash = this._hash;
  9586  	            var H = hash.words;
  9587  
  9588  	            // Swap endian
  9589  	            for (var i = 0; i < 4; i++) {
  9590  	                // Shortcut
  9591  	                var H_i = H[i];
  9592  
  9593  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
  9594  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
  9595  	            }
  9596  
  9597  	            // Return final computed hash
  9598  	            return hash;
  9599  	        },
  9600  
  9601  	        clone: function () {
  9602  	            var clone = Hasher.clone.call(this);
  9603  	            clone._hash = this._hash.clone();
  9604  
  9605  	            return clone;
  9606  	        }
  9607  	    });
  9608  
  9609  	    function FF(a, b, c, d, x, s, t) {
  9610  	        var n = a + ((b & c) | (~b & d)) + x + t;
  9611  	        return ((n << s) | (n >>> (32 - s))) + b;
  9612  	    }
  9613  
  9614  	    function GG(a, b, c, d, x, s, t) {
  9615  	        var n = a + ((b & d) | (c & ~d)) + x + t;
  9616  	        return ((n << s) | (n >>> (32 - s))) + b;
  9617  	    }
  9618  
  9619  	    function HH(a, b, c, d, x, s, t) {
  9620  	        var n = a + (b ^ c ^ d) + x + t;
  9621  	        return ((n << s) | (n >>> (32 - s))) + b;
  9622  	    }
  9623  
  9624  	    function II(a, b, c, d, x, s, t) {
  9625  	        var n = a + (c ^ (b | ~d)) + x + t;
  9626  	        return ((n << s) | (n >>> (32 - s))) + b;
  9627  	    }
  9628  
  9629  	    /**
  9630  	     * Shortcut function to the hasher's object interface.
  9631  	     *
  9632  	     * @param {WordArray|string} message The message to hash.
  9633  	     *
  9634  	     * @return {WordArray} The hash.
  9635  	     *
  9636  	     * @static
  9637  	     *
  9638  	     * @example
  9639  	     *
  9640  	     *     var hash = CryptoJS.MD5('message');
  9641  	     *     var hash = CryptoJS.MD5(wordArray);
  9642  	     */
  9643  	    C.MD5 = Hasher._createHelper(MD5);
  9644  
  9645  	    /**
  9646  	     * Shortcut function to the HMAC's object interface.
  9647  	     *
  9648  	     * @param {WordArray|string} message The message to hash.
  9649  	     * @param {WordArray|string} key The secret key.
  9650  	     *
  9651  	     * @return {WordArray} The HMAC.
  9652  	     *
  9653  	     * @static
  9654  	     *
  9655  	     * @example
  9656  	     *
  9657  	     *     var hmac = CryptoJS.HmacMD5(message, key);
  9658  	     */
  9659  	    C.HmacMD5 = Hasher._createHmacHelper(MD5);
  9660  	}(Math));
  9661  
  9662  
  9663  	return CryptoJS.MD5;
  9664  
  9665  }));
  9666  },{"./core":53}],62:[function(require,module,exports){
  9667  ;(function (root, factory, undef) {
  9668  	if (typeof exports === "object") {
  9669  		// CommonJS
  9670  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9671  	}
  9672  	else if (typeof define === "function" && define.amd) {
  9673  		// AMD
  9674  		define(["./core", "./cipher-core"], factory);
  9675  	}
  9676  	else {
  9677  		// Global (browser)
  9678  		factory(root.CryptoJS);
  9679  	}
  9680  }(this, function (CryptoJS) {
  9681  
  9682  	/**
  9683  	 * Cipher Feedback block mode.
  9684  	 */
  9685  	CryptoJS.mode.CFB = (function () {
  9686  	    var CFB = CryptoJS.lib.BlockCipherMode.extend();
  9687  
  9688  	    CFB.Encryptor = CFB.extend({
  9689  	        processBlock: function (words, offset) {
  9690  	            // Shortcuts
  9691  	            var cipher = this._cipher;
  9692  	            var blockSize = cipher.blockSize;
  9693  
  9694  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9695  
  9696  	            // Remember this block to use with next block
  9697  	            this._prevBlock = words.slice(offset, offset + blockSize);
  9698  	        }
  9699  	    });
  9700  
  9701  	    CFB.Decryptor = CFB.extend({
  9702  	        processBlock: function (words, offset) {
  9703  	            // Shortcuts
  9704  	            var cipher = this._cipher;
  9705  	            var blockSize = cipher.blockSize;
  9706  
  9707  	            // Remember this block to use with next block
  9708  	            var thisBlock = words.slice(offset, offset + blockSize);
  9709  
  9710  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9711  
  9712  	            // This block becomes the previous block
  9713  	            this._prevBlock = thisBlock;
  9714  	        }
  9715  	    });
  9716  
  9717  	    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  9718  	        // Shortcut
  9719  	        var iv = this._iv;
  9720  
  9721  	        // Generate keystream
  9722  	        if (iv) {
  9723  	            var keystream = iv.slice(0);
  9724  
  9725  	            // Remove IV for subsequent blocks
  9726  	            this._iv = undefined;
  9727  	        } else {
  9728  	            var keystream = this._prevBlock;
  9729  	        }
  9730  	        cipher.encryptBlock(keystream, 0);
  9731  
  9732  	        // Encrypt
  9733  	        for (var i = 0; i < blockSize; i++) {
  9734  	            words[offset + i] ^= keystream[i];
  9735  	        }
  9736  	    }
  9737  
  9738  	    return CFB;
  9739  	}());
  9740  
  9741  
  9742  	return CryptoJS.mode.CFB;
  9743  
  9744  }));
  9745  },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
  9746  ;(function (root, factory, undef) {
  9747  	if (typeof exports === "object") {
  9748  		// CommonJS
  9749  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9750  	}
  9751  	else if (typeof define === "function" && define.amd) {
  9752  		// AMD
  9753  		define(["./core", "./cipher-core"], factory);
  9754  	}
  9755  	else {
  9756  		// Global (browser)
  9757  		factory(root.CryptoJS);
  9758  	}
  9759  }(this, function (CryptoJS) {
  9760  
  9761  	/** @preserve
  9762  	 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
  9763  	 * derived from CryptoJS.mode.CTR
  9764  	 * Jan Hruby jhruby.web@gmail.com
  9765  	 */
  9766  	CryptoJS.mode.CTRGladman = (function () {
  9767  	    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  9768  
  9769  		function incWord(word)
  9770  		{
  9771  			if (((word >> 24) & 0xff) === 0xff) { //overflow
  9772  			var b1 = (word >> 16)&0xff;
  9773  			var b2 = (word >> 8)&0xff;
  9774  			var b3 = word & 0xff;
  9775  
  9776  			if (b1 === 0xff) // overflow b1
  9777  			{
  9778  			b1 = 0;
  9779  			if (b2 === 0xff)
  9780  			{
  9781  				b2 = 0;
  9782  				if (b3 === 0xff)
  9783  				{
  9784  					b3 = 0;
  9785  				}
  9786  				else
  9787  				{
  9788  					++b3;
  9789  				}
  9790  			}
  9791  			else
  9792  			{
  9793  				++b2;
  9794  			}
  9795  			}
  9796  			else
  9797  			{
  9798  			++b1;
  9799  			}
  9800  
  9801  			word = 0;
  9802  			word += (b1 << 16);
  9803  			word += (b2 << 8);
  9804  			word += b3;
  9805  			}
  9806  			else
  9807  			{
  9808  			word += (0x01 << 24);
  9809  			}
  9810  			return word;
  9811  		}
  9812  
  9813  		function incCounter(counter)
  9814  		{
  9815  			if ((counter[0] = incWord(counter[0])) === 0)
  9816  			{
  9817  				// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
  9818  				counter[1] = incWord(counter[1]);
  9819  			}
  9820  			return counter;
  9821  		}
  9822  
  9823  	    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  9824  	        processBlock: function (words, offset) {
  9825  	            // Shortcuts
  9826  	            var cipher = this._cipher
  9827  	            var blockSize = cipher.blockSize;
  9828  	            var iv = this._iv;
  9829  	            var counter = this._counter;
  9830  
  9831  	            // Generate keystream
  9832  	            if (iv) {
  9833  	                counter = this._counter = iv.slice(0);
  9834  
  9835  	                // Remove IV for subsequent blocks
  9836  	                this._iv = undefined;
  9837  	            }
  9838  
  9839  				incCounter(counter);
  9840  
  9841  				var keystream = counter.slice(0);
  9842  	            cipher.encryptBlock(keystream, 0);
  9843  
  9844  	            // Encrypt
  9845  	            for (var i = 0; i < blockSize; i++) {
  9846  	                words[offset + i] ^= keystream[i];
  9847  	            }
  9848  	        }
  9849  	    });
  9850  
  9851  	    CTRGladman.Decryptor = Encryptor;
  9852  
  9853  	    return CTRGladman;
  9854  	}());
  9855  
  9856  
  9857  
  9858  
  9859  	return CryptoJS.mode.CTRGladman;
  9860  
  9861  }));
  9862  },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
  9863  ;(function (root, factory, undef) {
  9864  	if (typeof exports === "object") {
  9865  		// CommonJS
  9866  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9867  	}
  9868  	else if (typeof define === "function" && define.amd) {
  9869  		// AMD
  9870  		define(["./core", "./cipher-core"], factory);
  9871  	}
  9872  	else {
  9873  		// Global (browser)
  9874  		factory(root.CryptoJS);
  9875  	}
  9876  }(this, function (CryptoJS) {
  9877  
  9878  	/**
  9879  	 * Counter block mode.
  9880  	 */
  9881  	CryptoJS.mode.CTR = (function () {
  9882  	    var CTR = CryptoJS.lib.BlockCipherMode.extend();
  9883  
  9884  	    var Encryptor = CTR.Encryptor = CTR.extend({
  9885  	        processBlock: function (words, offset) {
  9886  	            // Shortcuts
  9887  	            var cipher = this._cipher
  9888  	            var blockSize = cipher.blockSize;
  9889  	            var iv = this._iv;
  9890  	            var counter = this._counter;
  9891  
  9892  	            // Generate keystream
  9893  	            if (iv) {
  9894  	                counter = this._counter = iv.slice(0);
  9895  
  9896  	                // Remove IV for subsequent blocks
  9897  	                this._iv = undefined;
  9898  	            }
  9899  	            var keystream = counter.slice(0);
  9900  	            cipher.encryptBlock(keystream, 0);
  9901  
  9902  	            // Increment counter
  9903  	            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  9904  
  9905  	            // Encrypt
  9906  	            for (var i = 0; i < blockSize; i++) {
  9907  	                words[offset + i] ^= keystream[i];
  9908  	            }
  9909  	        }
  9910  	    });
  9911  
  9912  	    CTR.Decryptor = Encryptor;
  9913  
  9914  	    return CTR;
  9915  	}());
  9916  
  9917  
  9918  	return CryptoJS.mode.CTR;
  9919  
  9920  }));
  9921  },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
  9922  ;(function (root, factory, undef) {
  9923  	if (typeof exports === "object") {
  9924  		// CommonJS
  9925  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9926  	}
  9927  	else if (typeof define === "function" && define.amd) {
  9928  		// AMD
  9929  		define(["./core", "./cipher-core"], factory);
  9930  	}
  9931  	else {
  9932  		// Global (browser)
  9933  		factory(root.CryptoJS);
  9934  	}
  9935  }(this, function (CryptoJS) {
  9936  
  9937  	/**
  9938  	 * Electronic Codebook block mode.
  9939  	 */
  9940  	CryptoJS.mode.ECB = (function () {
  9941  	    var ECB = CryptoJS.lib.BlockCipherMode.extend();
  9942  
  9943  	    ECB.Encryptor = ECB.extend({
  9944  	        processBlock: function (words, offset) {
  9945  	            this._cipher.encryptBlock(words, offset);
  9946  	        }
  9947  	    });
  9948  
  9949  	    ECB.Decryptor = ECB.extend({
  9950  	        processBlock: function (words, offset) {
  9951  	            this._cipher.decryptBlock(words, offset);
  9952  	        }
  9953  	    });
  9954  
  9955  	    return ECB;
  9956  	}());
  9957  
  9958  
  9959  	return CryptoJS.mode.ECB;
  9960  
  9961  }));
  9962  },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
  9963  ;(function (root, factory, undef) {
  9964  	if (typeof exports === "object") {
  9965  		// CommonJS
  9966  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9967  	}
  9968  	else if (typeof define === "function" && define.amd) {
  9969  		// AMD
  9970  		define(["./core", "./cipher-core"], factory);
  9971  	}
  9972  	else {
  9973  		// Global (browser)
  9974  		factory(root.CryptoJS);
  9975  	}
  9976  }(this, function (CryptoJS) {
  9977  
  9978  	/**
  9979  	 * Output Feedback block mode.
  9980  	 */
  9981  	CryptoJS.mode.OFB = (function () {
  9982  	    var OFB = CryptoJS.lib.BlockCipherMode.extend();
  9983  
  9984  	    var Encryptor = OFB.Encryptor = OFB.extend({
  9985  	        processBlock: function (words, offset) {
  9986  	            // Shortcuts
  9987  	            var cipher = this._cipher
  9988  	            var blockSize = cipher.blockSize;
  9989  	            var iv = this._iv;
  9990  	            var keystream = this._keystream;
  9991  
  9992  	            // Generate keystream
  9993  	            if (iv) {
  9994  	                keystream = this._keystream = iv.slice(0);
  9995  
  9996  	                // Remove IV for subsequent blocks
  9997  	                this._iv = undefined;
  9998  	            }
  9999  	            cipher.encryptBlock(keystream, 0);
 10000  
 10001  	            // Encrypt
 10002  	            for (var i = 0; i < blockSize; i++) {
 10003  	                words[offset + i] ^= keystream[i];
 10004  	            }
 10005  	        }
 10006  	    });
 10007  
 10008  	    OFB.Decryptor = Encryptor;
 10009  
 10010  	    return OFB;
 10011  	}());
 10012  
 10013  
 10014  	return CryptoJS.mode.OFB;
 10015  
 10016  }));
 10017  },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
 10018  ;(function (root, factory, undef) {
 10019  	if (typeof exports === "object") {
 10020  		// CommonJS
 10021  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10022  	}
 10023  	else if (typeof define === "function" && define.amd) {
 10024  		// AMD
 10025  		define(["./core", "./cipher-core"], factory);
 10026  	}
 10027  	else {
 10028  		// Global (browser)
 10029  		factory(root.CryptoJS);
 10030  	}
 10031  }(this, function (CryptoJS) {
 10032  
 10033  	/**
 10034  	 * ANSI X.923 padding strategy.
 10035  	 */
 10036  	CryptoJS.pad.AnsiX923 = {
 10037  	    pad: function (data, blockSize) {
 10038  	        // Shortcuts
 10039  	        var dataSigBytes = data.sigBytes;
 10040  	        var blockSizeBytes = blockSize * 4;
 10041  
 10042  	        // Count padding bytes
 10043  	        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
 10044  
 10045  	        // Compute last byte position
 10046  	        var lastBytePos = dataSigBytes + nPaddingBytes - 1;
 10047  
 10048  	        // Pad
 10049  	        data.clamp();
 10050  	        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
 10051  	        data.sigBytes += nPaddingBytes;
 10052  	    },
 10053  
 10054  	    unpad: function (data) {
 10055  	        // Get number of padding bytes from last byte
 10056  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
 10057  
 10058  	        // Remove padding
 10059  	        data.sigBytes -= nPaddingBytes;
 10060  	    }
 10061  	};
 10062  
 10063  
 10064  	return CryptoJS.pad.Ansix923;
 10065  
 10066  }));
 10067  },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
 10068  ;(function (root, factory, undef) {
 10069  	if (typeof exports === "object") {
 10070  		// CommonJS
 10071  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10072  	}
 10073  	else if (typeof define === "function" && define.amd) {
 10074  		// AMD
 10075  		define(["./core", "./cipher-core"], factory);
 10076  	}
 10077  	else {
 10078  		// Global (browser)
 10079  		factory(root.CryptoJS);
 10080  	}
 10081  }(this, function (CryptoJS) {
 10082  
 10083  	/**
 10084  	 * ISO 10126 padding strategy.
 10085  	 */
 10086  	CryptoJS.pad.Iso10126 = {
 10087  	    pad: function (data, blockSize) {
 10088  	        // Shortcut
 10089  	        var blockSizeBytes = blockSize * 4;
 10090  
 10091  	        // Count padding bytes
 10092  	        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
 10093  
 10094  	        // Pad
 10095  	        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
 10096  	             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
 10097  	    },
 10098  
 10099  	    unpad: function (data) {
 10100  	        // Get number of padding bytes from last byte
 10101  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
 10102  
 10103  	        // Remove padding
 10104  	        data.sigBytes -= nPaddingBytes;
 10105  	    }
 10106  	};
 10107  
 10108  
 10109  	return CryptoJS.pad.Iso10126;
 10110  
 10111  }));
 10112  },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
 10113  ;(function (root, factory, undef) {
 10114  	if (typeof exports === "object") {
 10115  		// CommonJS
 10116  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10117  	}
 10118  	else if (typeof define === "function" && define.amd) {
 10119  		// AMD
 10120  		define(["./core", "./cipher-core"], factory);
 10121  	}
 10122  	else {
 10123  		// Global (browser)
 10124  		factory(root.CryptoJS);
 10125  	}
 10126  }(this, function (CryptoJS) {
 10127  
 10128  	/**
 10129  	 * ISO/IEC 9797-1 Padding Method 2.
 10130  	 */
 10131  	CryptoJS.pad.Iso97971 = {
 10132  	    pad: function (data, blockSize) {
 10133  	        // Add 0x80 byte
 10134  	        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
 10135  
 10136  	        // Zero pad the rest
 10137  	        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
 10138  	    },
 10139  
 10140  	    unpad: function (data) {
 10141  	        // Remove zero padding
 10142  	        CryptoJS.pad.ZeroPadding.unpad(data);
 10143  
 10144  	        // Remove one more byte -- the 0x80 byte
 10145  	        data.sigBytes--;
 10146  	    }
 10147  	};
 10148  
 10149  
 10150  	return CryptoJS.pad.Iso97971;
 10151  
 10152  }));
 10153  },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
 10154  ;(function (root, factory, undef) {
 10155  	if (typeof exports === "object") {
 10156  		// CommonJS
 10157  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10158  	}
 10159  	else if (typeof define === "function" && define.amd) {
 10160  		// AMD
 10161  		define(["./core", "./cipher-core"], factory);
 10162  	}
 10163  	else {
 10164  		// Global (browser)
 10165  		factory(root.CryptoJS);
 10166  	}
 10167  }(this, function (CryptoJS) {
 10168  
 10169  	/**
 10170  	 * A noop padding strategy.
 10171  	 */
 10172  	CryptoJS.pad.NoPadding = {
 10173  	    pad: function () {
 10174  	    },
 10175  
 10176  	    unpad: function () {
 10177  	    }
 10178  	};
 10179  
 10180  
 10181  	return CryptoJS.pad.NoPadding;
 10182  
 10183  }));
 10184  },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
 10185  ;(function (root, factory, undef) {
 10186  	if (typeof exports === "object") {
 10187  		// CommonJS
 10188  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10189  	}
 10190  	else if (typeof define === "function" && define.amd) {
 10191  		// AMD
 10192  		define(["./core", "./cipher-core"], factory);
 10193  	}
 10194  	else {
 10195  		// Global (browser)
 10196  		factory(root.CryptoJS);
 10197  	}
 10198  }(this, function (CryptoJS) {
 10199  
 10200  	/**
 10201  	 * Zero padding strategy.
 10202  	 */
 10203  	CryptoJS.pad.ZeroPadding = {
 10204  	    pad: function (data, blockSize) {
 10205  	        // Shortcut
 10206  	        var blockSizeBytes = blockSize * 4;
 10207  
 10208  	        // Pad
 10209  	        data.clamp();
 10210  	        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
 10211  	    },
 10212  
 10213  	    unpad: function (data) {
 10214  	        // Shortcut
 10215  	        var dataWords = data.words;
 10216  
 10217  	        // Unpad
 10218  	        var i = data.sigBytes - 1;
 10219  	        while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
 10220  	            i--;
 10221  	        }
 10222  	        data.sigBytes = i + 1;
 10223  	    }
 10224  	};
 10225  
 10226  
 10227  	return CryptoJS.pad.ZeroPadding;
 10228  
 10229  }));
 10230  },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
 10231  ;(function (root, factory, undef) {
 10232  	if (typeof exports === "object") {
 10233  		// CommonJS
 10234  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
 10235  	}
 10236  	else if (typeof define === "function" && define.amd) {
 10237  		// AMD
 10238  		define(["./core", "./sha1", "./hmac"], factory);
 10239  	}
 10240  	else {
 10241  		// Global (browser)
 10242  		factory(root.CryptoJS);
 10243  	}
 10244  }(this, function (CryptoJS) {
 10245  
 10246  	(function () {
 10247  	    // Shortcuts
 10248  	    var C = CryptoJS;
 10249  	    var C_lib = C.lib;
 10250  	    var Base = C_lib.Base;
 10251  	    var WordArray = C_lib.WordArray;
 10252  	    var C_algo = C.algo;
 10253  	    var SHA1 = C_algo.SHA1;
 10254  	    var HMAC = C_algo.HMAC;
 10255  
 10256  	    /**
 10257  	     * Password-Based Key Derivation Function 2 algorithm.
 10258  	     */
 10259  	    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
 10260  	        /**
 10261  	         * Configuration options.
 10262  	         *
 10263  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
 10264  	         * @property {Hasher} hasher The hasher to use. Default: SHA1
 10265  	         * @property {number} iterations The number of iterations to perform. Default: 1
 10266  	         */
 10267  	        cfg: Base.extend({
 10268  	            keySize: 128/32,
 10269  	            hasher: SHA1,
 10270  	            iterations: 1
 10271  	        }),
 10272  
 10273  	        /**
 10274  	         * Initializes a newly created key derivation function.
 10275  	         *
 10276  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
 10277  	         *
 10278  	         * @example
 10279  	         *
 10280  	         *     var kdf = CryptoJS.algo.PBKDF2.create();
 10281  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
 10282  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
 10283  	         */
 10284  	        init: function (cfg) {
 10285  	            this.cfg = this.cfg.extend(cfg);
 10286  	        },
 10287  
 10288  	        /**
 10289  	         * Computes the Password-Based Key Derivation Function 2.
 10290  	         *
 10291  	         * @param {WordArray|string} password The password.
 10292  	         * @param {WordArray|string} salt A salt.
 10293  	         *
 10294  	         * @return {WordArray} The derived key.
 10295  	         *
 10296  	         * @example
 10297  	         *
 10298  	         *     var key = kdf.compute(password, salt);
 10299  	         */
 10300  	        compute: function (password, salt) {
 10301  	            // Shortcut
 10302  	            var cfg = this.cfg;
 10303  
 10304  	            // Init HMAC
 10305  	            var hmac = HMAC.create(cfg.hasher, password);
 10306  
 10307  	            // Initial values
 10308  	            var derivedKey = WordArray.create();
 10309  	            var blockIndex = WordArray.create([0x00000001]);
 10310  
 10311  	            // Shortcuts
 10312  	            var derivedKeyWords = derivedKey.words;
 10313  	            var blockIndexWords = blockIndex.words;
 10314  	            var keySize = cfg.keySize;
 10315  	            var iterations = cfg.iterations;
 10316  
 10317  	            // Generate key
 10318  	            while (derivedKeyWords.length < keySize) {
 10319  	                var block = hmac.update(salt).finalize(blockIndex);
 10320  	                hmac.reset();
 10321  
 10322  	                // Shortcuts
 10323  	                var blockWords = block.words;
 10324  	                var blockWordsLength = blockWords.length;
 10325  
 10326  	                // Iterations
 10327  	                var intermediate = block;
 10328  	                for (var i = 1; i < iterations; i++) {
 10329  	                    intermediate = hmac.finalize(intermediate);
 10330  	                    hmac.reset();
 10331  
 10332  	                    // Shortcut
 10333  	                    var intermediateWords = intermediate.words;
 10334  
 10335  	                    // XOR intermediate with block
 10336  	                    for (var j = 0; j < blockWordsLength; j++) {
 10337  	                        blockWords[j] ^= intermediateWords[j];
 10338  	                    }
 10339  	                }
 10340  
 10341  	                derivedKey.concat(block);
 10342  	                blockIndexWords[0]++;
 10343  	            }
 10344  	            derivedKey.sigBytes = keySize * 4;
 10345  
 10346  	            return derivedKey;
 10347  	        }
 10348  	    });
 10349  
 10350  	    /**
 10351  	     * Computes the Password-Based Key Derivation Function 2.
 10352  	     *
 10353  	     * @param {WordArray|string} password The password.
 10354  	     * @param {WordArray|string} salt A salt.
 10355  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
 10356  	     *
 10357  	     * @return {WordArray} The derived key.
 10358  	     *
 10359  	     * @static
 10360  	     *
 10361  	     * @example
 10362  	     *
 10363  	     *     var key = CryptoJS.PBKDF2(password, salt);
 10364  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
 10365  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
 10366  	     */
 10367  	    C.PBKDF2 = function (password, salt, cfg) {
 10368  	        return PBKDF2.create(cfg).compute(password, salt);
 10369  	    };
 10370  	}());
 10371  
 10372  
 10373  	return CryptoJS.PBKDF2;
 10374  
 10375  }));
 10376  },{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
 10377  ;(function (root, factory, undef) {
 10378  	if (typeof exports === "object") {
 10379  		// CommonJS
 10380  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10381  	}
 10382  	else if (typeof define === "function" && define.amd) {
 10383  		// AMD
 10384  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10385  	}
 10386  	else {
 10387  		// Global (browser)
 10388  		factory(root.CryptoJS);
 10389  	}
 10390  }(this, function (CryptoJS) {
 10391  
 10392  	(function () {
 10393  	    // Shortcuts
 10394  	    var C = CryptoJS;
 10395  	    var C_lib = C.lib;
 10396  	    var StreamCipher = C_lib.StreamCipher;
 10397  	    var C_algo = C.algo;
 10398  
 10399  	    // Reusable objects
 10400  	    var S  = [];
 10401  	    var C_ = [];
 10402  	    var G  = [];
 10403  
 10404  	    /**
 10405  	     * Rabbit stream cipher algorithm.
 10406  	     *
 10407  	     * This is a legacy version that neglected to convert the key to little-endian.
 10408  	     * This error doesn't affect the cipher's security,
 10409  	     * but it does affect its compatibility with other implementations.
 10410  	     */
 10411  	    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
 10412  	        _doReset: function () {
 10413  	            // Shortcuts
 10414  	            var K = this._key.words;
 10415  	            var iv = this.cfg.iv;
 10416  
 10417  	            // Generate initial state values
 10418  	            var X = this._X = [
 10419  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10420  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10421  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10422  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10423  	            ];
 10424  
 10425  	            // Generate initial counter values
 10426  	            var C = this._C = [
 10427  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10428  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10429  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10430  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10431  	            ];
 10432  
 10433  	            // Carry bit
 10434  	            this._b = 0;
 10435  
 10436  	            // Iterate the system four times
 10437  	            for (var i = 0; i < 4; i++) {
 10438  	                nextState.call(this);
 10439  	            }
 10440  
 10441  	            // Modify the counters
 10442  	            for (var i = 0; i < 8; i++) {
 10443  	                C[i] ^= X[(i + 4) & 7];
 10444  	            }
 10445  
 10446  	            // IV setup
 10447  	            if (iv) {
 10448  	                // Shortcuts
 10449  	                var IV = iv.words;
 10450  	                var IV_0 = IV[0];
 10451  	                var IV_1 = IV[1];
 10452  
 10453  	                // Generate four subvectors
 10454  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10455  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10456  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10457  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10458  
 10459  	                // Modify counter values
 10460  	                C[0] ^= i0;
 10461  	                C[1] ^= i1;
 10462  	                C[2] ^= i2;
 10463  	                C[3] ^= i3;
 10464  	                C[4] ^= i0;
 10465  	                C[5] ^= i1;
 10466  	                C[6] ^= i2;
 10467  	                C[7] ^= i3;
 10468  
 10469  	                // Iterate the system four times
 10470  	                for (var i = 0; i < 4; i++) {
 10471  	                    nextState.call(this);
 10472  	                }
 10473  	            }
 10474  	        },
 10475  
 10476  	        _doProcessBlock: function (M, offset) {
 10477  	            // Shortcut
 10478  	            var X = this._X;
 10479  
 10480  	            // Iterate the system
 10481  	            nextState.call(this);
 10482  
 10483  	            // Generate four keystream words
 10484  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10485  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10486  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10487  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10488  
 10489  	            for (var i = 0; i < 4; i++) {
 10490  	                // Swap endian
 10491  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10492  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10493  
 10494  	                // Encrypt
 10495  	                M[offset + i] ^= S[i];
 10496  	            }
 10497  	        },
 10498  
 10499  	        blockSize: 128/32,
 10500  
 10501  	        ivSize: 64/32
 10502  	    });
 10503  
 10504  	    function nextState() {
 10505  	        // Shortcuts
 10506  	        var X = this._X;
 10507  	        var C = this._C;
 10508  
 10509  	        // Save old counter values
 10510  	        for (var i = 0; i < 8; i++) {
 10511  	            C_[i] = C[i];
 10512  	        }
 10513  
 10514  	        // Calculate new counter values
 10515  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10516  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10517  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10518  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10519  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10520  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10521  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10522  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10523  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10524  
 10525  	        // Calculate the g-values
 10526  	        for (var i = 0; i < 8; i++) {
 10527  	            var gx = X[i] + C[i];
 10528  
 10529  	            // Construct high and low argument for squaring
 10530  	            var ga = gx & 0xffff;
 10531  	            var gb = gx >>> 16;
 10532  
 10533  	            // Calculate high and low result of squaring
 10534  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10535  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10536  
 10537  	            // High XOR low
 10538  	            G[i] = gh ^ gl;
 10539  	        }
 10540  
 10541  	        // Calculate new state values
 10542  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10543  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10544  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10545  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10546  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10547  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10548  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10549  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10550  	    }
 10551  
 10552  	    /**
 10553  	     * Shortcut functions to the cipher's object interface.
 10554  	     *
 10555  	     * @example
 10556  	     *
 10557  	     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
 10558  	     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
 10559  	     */
 10560  	    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
 10561  	}());
 10562  
 10563  
 10564  	return CryptoJS.RabbitLegacy;
 10565  
 10566  }));
 10567  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
 10568  ;(function (root, factory, undef) {
 10569  	if (typeof exports === "object") {
 10570  		// CommonJS
 10571  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10572  	}
 10573  	else if (typeof define === "function" && define.amd) {
 10574  		// AMD
 10575  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10576  	}
 10577  	else {
 10578  		// Global (browser)
 10579  		factory(root.CryptoJS);
 10580  	}
 10581  }(this, function (CryptoJS) {
 10582  
 10583  	(function () {
 10584  	    // Shortcuts
 10585  	    var C = CryptoJS;
 10586  	    var C_lib = C.lib;
 10587  	    var StreamCipher = C_lib.StreamCipher;
 10588  	    var C_algo = C.algo;
 10589  
 10590  	    // Reusable objects
 10591  	    var S  = [];
 10592  	    var C_ = [];
 10593  	    var G  = [];
 10594  
 10595  	    /**
 10596  	     * Rabbit stream cipher algorithm
 10597  	     */
 10598  	    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
 10599  	        _doReset: function () {
 10600  	            // Shortcuts
 10601  	            var K = this._key.words;
 10602  	            var iv = this.cfg.iv;
 10603  
 10604  	            // Swap endian
 10605  	            for (var i = 0; i < 4; i++) {
 10606  	                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
 10607  	                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
 10608  	            }
 10609  
 10610  	            // Generate initial state values
 10611  	            var X = this._X = [
 10612  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10613  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10614  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10615  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10616  	            ];
 10617  
 10618  	            // Generate initial counter values
 10619  	            var C = this._C = [
 10620  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10621  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10622  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10623  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10624  	            ];
 10625  
 10626  	            // Carry bit
 10627  	            this._b = 0;
 10628  
 10629  	            // Iterate the system four times
 10630  	            for (var i = 0; i < 4; i++) {
 10631  	                nextState.call(this);
 10632  	            }
 10633  
 10634  	            // Modify the counters
 10635  	            for (var i = 0; i < 8; i++) {
 10636  	                C[i] ^= X[(i + 4) & 7];
 10637  	            }
 10638  
 10639  	            // IV setup
 10640  	            if (iv) {
 10641  	                // Shortcuts
 10642  	                var IV = iv.words;
 10643  	                var IV_0 = IV[0];
 10644  	                var IV_1 = IV[1];
 10645  
 10646  	                // Generate four subvectors
 10647  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10648  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10649  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10650  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10651  
 10652  	                // Modify counter values
 10653  	                C[0] ^= i0;
 10654  	                C[1] ^= i1;
 10655  	                C[2] ^= i2;
 10656  	                C[3] ^= i3;
 10657  	                C[4] ^= i0;
 10658  	                C[5] ^= i1;
 10659  	                C[6] ^= i2;
 10660  	                C[7] ^= i3;
 10661  
 10662  	                // Iterate the system four times
 10663  	                for (var i = 0; i < 4; i++) {
 10664  	                    nextState.call(this);
 10665  	                }
 10666  	            }
 10667  	        },
 10668  
 10669  	        _doProcessBlock: function (M, offset) {
 10670  	            // Shortcut
 10671  	            var X = this._X;
 10672  
 10673  	            // Iterate the system
 10674  	            nextState.call(this);
 10675  
 10676  	            // Generate four keystream words
 10677  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10678  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10679  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10680  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10681  
 10682  	            for (var i = 0; i < 4; i++) {
 10683  	                // Swap endian
 10684  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10685  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10686  
 10687  	                // Encrypt
 10688  	                M[offset + i] ^= S[i];
 10689  	            }
 10690  	        },
 10691  
 10692  	        blockSize: 128/32,
 10693  
 10694  	        ivSize: 64/32
 10695  	    });
 10696  
 10697  	    function nextState() {
 10698  	        // Shortcuts
 10699  	        var X = this._X;
 10700  	        var C = this._C;
 10701  
 10702  	        // Save old counter values
 10703  	        for (var i = 0; i < 8; i++) {
 10704  	            C_[i] = C[i];
 10705  	        }
 10706  
 10707  	        // Calculate new counter values
 10708  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10709  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10710  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10711  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10712  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10713  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10714  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10715  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10716  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10717  
 10718  	        // Calculate the g-values
 10719  	        for (var i = 0; i < 8; i++) {
 10720  	            var gx = X[i] + C[i];
 10721  
 10722  	            // Construct high and low argument for squaring
 10723  	            var ga = gx & 0xffff;
 10724  	            var gb = gx >>> 16;
 10725  
 10726  	            // Calculate high and low result of squaring
 10727  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10728  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10729  
 10730  	            // High XOR low
 10731  	            G[i] = gh ^ gl;
 10732  	        }
 10733  
 10734  	        // Calculate new state values
 10735  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10736  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10737  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10738  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10739  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10740  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10741  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10742  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10743  	    }
 10744  
 10745  	    /**
 10746  	     * Shortcut functions to the cipher's object interface.
 10747  	     *
 10748  	     * @example
 10749  	     *
 10750  	     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
 10751  	     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
 10752  	     */
 10753  	    C.Rabbit = StreamCipher._createHelper(Rabbit);
 10754  	}());
 10755  
 10756  
 10757  	return CryptoJS.Rabbit;
 10758  
 10759  }));
 10760  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
 10761  ;(function (root, factory, undef) {
 10762  	if (typeof exports === "object") {
 10763  		// CommonJS
 10764  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10765  	}
 10766  	else if (typeof define === "function" && define.amd) {
 10767  		// AMD
 10768  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10769  	}
 10770  	else {
 10771  		// Global (browser)
 10772  		factory(root.CryptoJS);
 10773  	}
 10774  }(this, function (CryptoJS) {
 10775  
 10776  	(function () {
 10777  	    // Shortcuts
 10778  	    var C = CryptoJS;
 10779  	    var C_lib = C.lib;
 10780  	    var StreamCipher = C_lib.StreamCipher;
 10781  	    var C_algo = C.algo;
 10782  
 10783  	    /**
 10784  	     * RC4 stream cipher algorithm.
 10785  	     */
 10786  	    var RC4 = C_algo.RC4 = StreamCipher.extend({
 10787  	        _doReset: function () {
 10788  	            // Shortcuts
 10789  	            var key = this._key;
 10790  	            var keyWords = key.words;
 10791  	            var keySigBytes = key.sigBytes;
 10792  
 10793  	            // Init sbox
 10794  	            var S = this._S = [];
 10795  	            for (var i = 0; i < 256; i++) {
 10796  	                S[i] = i;
 10797  	            }
 10798  
 10799  	            // Key setup
 10800  	            for (var i = 0, j = 0; i < 256; i++) {
 10801  	                var keyByteIndex = i % keySigBytes;
 10802  	                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
 10803  
 10804  	                j = (j + S[i] + keyByte) % 256;
 10805  
 10806  	                // Swap
 10807  	                var t = S[i];
 10808  	                S[i] = S[j];
 10809  	                S[j] = t;
 10810  	            }
 10811  
 10812  	            // Counters
 10813  	            this._i = this._j = 0;
 10814  	        },
 10815  
 10816  	        _doProcessBlock: function (M, offset) {
 10817  	            M[offset] ^= generateKeystreamWord.call(this);
 10818  	        },
 10819  
 10820  	        keySize: 256/32,
 10821  
 10822  	        ivSize: 0
 10823  	    });
 10824  
 10825  	    function generateKeystreamWord() {
 10826  	        // Shortcuts
 10827  	        var S = this._S;
 10828  	        var i = this._i;
 10829  	        var j = this._j;
 10830  
 10831  	        // Generate keystream word
 10832  	        var keystreamWord = 0;
 10833  	        for (var n = 0; n < 4; n++) {
 10834  	            i = (i + 1) % 256;
 10835  	            j = (j + S[i]) % 256;
 10836  
 10837  	            // Swap
 10838  	            var t = S[i];
 10839  	            S[i] = S[j];
 10840  	            S[j] = t;
 10841  
 10842  	            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
 10843  	        }
 10844  
 10845  	        // Update counters
 10846  	        this._i = i;
 10847  	        this._j = j;
 10848  
 10849  	        return keystreamWord;
 10850  	    }
 10851  
 10852  	    /**
 10853  	     * Shortcut functions to the cipher's object interface.
 10854  	     *
 10855  	     * @example
 10856  	     *
 10857  	     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
 10858  	     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
 10859  	     */
 10860  	    C.RC4 = StreamCipher._createHelper(RC4);
 10861  
 10862  	    /**
 10863  	     * Modified RC4 stream cipher algorithm.
 10864  	     */
 10865  	    var RC4Drop = C_algo.RC4Drop = RC4.extend({
 10866  	        /**
 10867  	         * Configuration options.
 10868  	         *
 10869  	         * @property {number} drop The number of keystream words to drop. Default 192
 10870  	         */
 10871  	        cfg: RC4.cfg.extend({
 10872  	            drop: 192
 10873  	        }),
 10874  
 10875  	        _doReset: function () {
 10876  	            RC4._doReset.call(this);
 10877  
 10878  	            // Drop
 10879  	            for (var i = this.cfg.drop; i > 0; i--) {
 10880  	                generateKeystreamWord.call(this);
 10881  	            }
 10882  	        }
 10883  	    });
 10884  
 10885  	    /**
 10886  	     * Shortcut functions to the cipher's object interface.
 10887  	     *
 10888  	     * @example
 10889  	     *
 10890  	     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
 10891  	     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
 10892  	     */
 10893  	    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
 10894  	}());
 10895  
 10896  
 10897  	return CryptoJS.RC4;
 10898  
 10899  }));
 10900  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
 10901  ;(function (root, factory) {
 10902  	if (typeof exports === "object") {
 10903  		// CommonJS
 10904  		module.exports = exports = factory(require("./core"));
 10905  	}
 10906  	else if (typeof define === "function" && define.amd) {
 10907  		// AMD
 10908  		define(["./core"], factory);
 10909  	}
 10910  	else {
 10911  		// Global (browser)
 10912  		factory(root.CryptoJS);
 10913  	}
 10914  }(this, function (CryptoJS) {
 10915  
 10916  	/** @preserve
 10917  	(c) 2012 by Cédric Mesnil. All rights reserved.
 10918  
 10919  	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 10920  
 10921  	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 10922  	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 10923  
 10924  	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 10925  	*/
 10926  
 10927  	(function (Math) {
 10928  	    // Shortcuts
 10929  	    var C = CryptoJS;
 10930  	    var C_lib = C.lib;
 10931  	    var WordArray = C_lib.WordArray;
 10932  	    var Hasher = C_lib.Hasher;
 10933  	    var C_algo = C.algo;
 10934  
 10935  	    // Constants table
 10936  	    var _zl = WordArray.create([
 10937  	        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 10938  	        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
 10939  	        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
 10940  	        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
 10941  	        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
 10942  	    var _zr = WordArray.create([
 10943  	        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
 10944  	        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
 10945  	        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
 10946  	        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
 10947  	        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
 10948  	    var _sl = WordArray.create([
 10949  	         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
 10950  	        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
 10951  	        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
 10952  	          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
 10953  	        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
 10954  	    var _sr = WordArray.create([
 10955  	        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
 10956  	        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
 10957  	        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
 10958  	        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
 10959  	        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
 10960  
 10961  	    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
 10962  	    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
 10963  
 10964  	    /**
 10965  	     * RIPEMD160 hash algorithm.
 10966  	     */
 10967  	    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
 10968  	        _doReset: function () {
 10969  	            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
 10970  	        },
 10971  
 10972  	        _doProcessBlock: function (M, offset) {
 10973  
 10974  	            // Swap endian
 10975  	            for (var i = 0; i < 16; i++) {
 10976  	                // Shortcuts
 10977  	                var offset_i = offset + i;
 10978  	                var M_offset_i = M[offset_i];
 10979  
 10980  	                // Swap
 10981  	                M[offset_i] = (
 10982  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
 10983  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
 10984  	                );
 10985  	            }
 10986  	            // Shortcut
 10987  	            var H  = this._hash.words;
 10988  	            var hl = _hl.words;
 10989  	            var hr = _hr.words;
 10990  	            var zl = _zl.words;
 10991  	            var zr = _zr.words;
 10992  	            var sl = _sl.words;
 10993  	            var sr = _sr.words;
 10994  
 10995  	            // Working variables
 10996  	            var al, bl, cl, dl, el;
 10997  	            var ar, br, cr, dr, er;
 10998  
 10999  	            ar = al = H[0];
 11000  	            br = bl = H[1];
 11001  	            cr = cl = H[2];
 11002  	            dr = dl = H[3];
 11003  	            er = el = H[4];
 11004  	            // Computation
 11005  	            var t;
 11006  	            for (var i = 0; i < 80; i += 1) {
 11007  	                t = (al +  M[offset+zl[i]])|0;
 11008  	                if (i<16){
 11009  		            t +=  f1(bl,cl,dl) + hl[0];
 11010  	                } else if (i<32) {
 11011  		            t +=  f2(bl,cl,dl) + hl[1];
 11012  	                } else if (i<48) {
 11013  		            t +=  f3(bl,cl,dl) + hl[2];
 11014  	                } else if (i<64) {
 11015  		            t +=  f4(bl,cl,dl) + hl[3];
 11016  	                } else {// if (i<80) {
 11017  		            t +=  f5(bl,cl,dl) + hl[4];
 11018  	                }
 11019  	                t = t|0;
 11020  	                t =  rotl(t,sl[i]);
 11021  	                t = (t+el)|0;
 11022  	                al = el;
 11023  	                el = dl;
 11024  	                dl = rotl(cl, 10);
 11025  	                cl = bl;
 11026  	                bl = t;
 11027  
 11028  	                t = (ar + M[offset+zr[i]])|0;
 11029  	                if (i<16){
 11030  		            t +=  f5(br,cr,dr) + hr[0];
 11031  	                } else if (i<32) {
 11032  		            t +=  f4(br,cr,dr) + hr[1];
 11033  	                } else if (i<48) {
 11034  		            t +=  f3(br,cr,dr) + hr[2];
 11035  	                } else if (i<64) {
 11036  		            t +=  f2(br,cr,dr) + hr[3];
 11037  	                } else {// if (i<80) {
 11038  		            t +=  f1(br,cr,dr) + hr[4];
 11039  	                }
 11040  	                t = t|0;
 11041  	                t =  rotl(t,sr[i]) ;
 11042  	                t = (t+er)|0;
 11043  	                ar = er;
 11044  	                er = dr;
 11045  	                dr = rotl(cr, 10);
 11046  	                cr = br;
 11047  	                br = t;
 11048  	            }
 11049  	            // Intermediate hash value
 11050  	            t    = (H[1] + cl + dr)|0;
 11051  	            H[1] = (H[2] + dl + er)|0;
 11052  	            H[2] = (H[3] + el + ar)|0;
 11053  	            H[3] = (H[4] + al + br)|0;
 11054  	            H[4] = (H[0] + bl + cr)|0;
 11055  	            H[0] =  t;
 11056  	        },
 11057  
 11058  	        _doFinalize: function () {
 11059  	            // Shortcuts
 11060  	            var data = this._data;
 11061  	            var dataWords = data.words;
 11062  
 11063  	            var nBitsTotal = this._nDataBytes * 8;
 11064  	            var nBitsLeft = data.sigBytes * 8;
 11065  
 11066  	            // Add padding
 11067  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11068  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
 11069  	                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
 11070  	                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
 11071  	            );
 11072  	            data.sigBytes = (dataWords.length + 1) * 4;
 11073  
 11074  	            // Hash final blocks
 11075  	            this._process();
 11076  
 11077  	            // Shortcuts
 11078  	            var hash = this._hash;
 11079  	            var H = hash.words;
 11080  
 11081  	            // Swap endian
 11082  	            for (var i = 0; i < 5; i++) {
 11083  	                // Shortcut
 11084  	                var H_i = H[i];
 11085  
 11086  	                // Swap
 11087  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
 11088  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
 11089  	            }
 11090  
 11091  	            // Return final computed hash
 11092  	            return hash;
 11093  	        },
 11094  
 11095  	        clone: function () {
 11096  	            var clone = Hasher.clone.call(this);
 11097  	            clone._hash = this._hash.clone();
 11098  
 11099  	            return clone;
 11100  	        }
 11101  	    });
 11102  
 11103  
 11104  	    function f1(x, y, z) {
 11105  	        return ((x) ^ (y) ^ (z));
 11106  
 11107  	    }
 11108  
 11109  	    function f2(x, y, z) {
 11110  	        return (((x)&(y)) | ((~x)&(z)));
 11111  	    }
 11112  
 11113  	    function f3(x, y, z) {
 11114  	        return (((x) | (~(y))) ^ (z));
 11115  	    }
 11116  
 11117  	    function f4(x, y, z) {
 11118  	        return (((x) & (z)) | ((y)&(~(z))));
 11119  	    }
 11120  
 11121  	    function f5(x, y, z) {
 11122  	        return ((x) ^ ((y) |(~(z))));
 11123  
 11124  	    }
 11125  
 11126  	    function rotl(x,n) {
 11127  	        return (x<<n) | (x>>>(32-n));
 11128  	    }
 11129  
 11130  
 11131  	    /**
 11132  	     * Shortcut function to the hasher's object interface.
 11133  	     *
 11134  	     * @param {WordArray|string} message The message to hash.
 11135  	     *
 11136  	     * @return {WordArray} The hash.
 11137  	     *
 11138  	     * @static
 11139  	     *
 11140  	     * @example
 11141  	     *
 11142  	     *     var hash = CryptoJS.RIPEMD160('message');
 11143  	     *     var hash = CryptoJS.RIPEMD160(wordArray);
 11144  	     */
 11145  	    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
 11146  
 11147  	    /**
 11148  	     * Shortcut function to the HMAC's object interface.
 11149  	     *
 11150  	     * @param {WordArray|string} message The message to hash.
 11151  	     * @param {WordArray|string} key The secret key.
 11152  	     *
 11153  	     * @return {WordArray} The HMAC.
 11154  	     *
 11155  	     * @static
 11156  	     *
 11157  	     * @example
 11158  	     *
 11159  	     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
 11160  	     */
 11161  	    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
 11162  	}(Math));
 11163  
 11164  
 11165  	return CryptoJS.RIPEMD160;
 11166  
 11167  }));
 11168  },{"./core":53}],77:[function(require,module,exports){
 11169  ;(function (root, factory) {
 11170  	if (typeof exports === "object") {
 11171  		// CommonJS
 11172  		module.exports = exports = factory(require("./core"));
 11173  	}
 11174  	else if (typeof define === "function" && define.amd) {
 11175  		// AMD
 11176  		define(["./core"], factory);
 11177  	}
 11178  	else {
 11179  		// Global (browser)
 11180  		factory(root.CryptoJS);
 11181  	}
 11182  }(this, function (CryptoJS) {
 11183  
 11184  	(function () {
 11185  	    // Shortcuts
 11186  	    var C = CryptoJS;
 11187  	    var C_lib = C.lib;
 11188  	    var WordArray = C_lib.WordArray;
 11189  	    var Hasher = C_lib.Hasher;
 11190  	    var C_algo = C.algo;
 11191  
 11192  	    // Reusable object
 11193  	    var W = [];
 11194  
 11195  	    /**
 11196  	     * SHA-1 hash algorithm.
 11197  	     */
 11198  	    var SHA1 = C_algo.SHA1 = Hasher.extend({
 11199  	        _doReset: function () {
 11200  	            this._hash = new WordArray.init([
 11201  	                0x67452301, 0xefcdab89,
 11202  	                0x98badcfe, 0x10325476,
 11203  	                0xc3d2e1f0
 11204  	            ]);
 11205  	        },
 11206  
 11207  	        _doProcessBlock: function (M, offset) {
 11208  	            // Shortcut
 11209  	            var H = this._hash.words;
 11210  
 11211  	            // Working variables
 11212  	            var a = H[0];
 11213  	            var b = H[1];
 11214  	            var c = H[2];
 11215  	            var d = H[3];
 11216  	            var e = H[4];
 11217  
 11218  	            // Computation
 11219  	            for (var i = 0; i < 80; i++) {
 11220  	                if (i < 16) {
 11221  	                    W[i] = M[offset + i] | 0;
 11222  	                } else {
 11223  	                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
 11224  	                    W[i] = (n << 1) | (n >>> 31);
 11225  	                }
 11226  
 11227  	                var t = ((a << 5) | (a >>> 27)) + e + W[i];
 11228  	                if (i < 20) {
 11229  	                    t += ((b & c) | (~b & d)) + 0x5a827999;
 11230  	                } else if (i < 40) {
 11231  	                    t += (b ^ c ^ d) + 0x6ed9eba1;
 11232  	                } else if (i < 60) {
 11233  	                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
 11234  	                } else /* if (i < 80) */ {
 11235  	                    t += (b ^ c ^ d) - 0x359d3e2a;
 11236  	                }
 11237  
 11238  	                e = d;
 11239  	                d = c;
 11240  	                c = (b << 30) | (b >>> 2);
 11241  	                b = a;
 11242  	                a = t;
 11243  	            }
 11244  
 11245  	            // Intermediate hash value
 11246  	            H[0] = (H[0] + a) | 0;
 11247  	            H[1] = (H[1] + b) | 0;
 11248  	            H[2] = (H[2] + c) | 0;
 11249  	            H[3] = (H[3] + d) | 0;
 11250  	            H[4] = (H[4] + e) | 0;
 11251  	        },
 11252  
 11253  	        _doFinalize: function () {
 11254  	            // Shortcuts
 11255  	            var data = this._data;
 11256  	            var dataWords = data.words;
 11257  
 11258  	            var nBitsTotal = this._nDataBytes * 8;
 11259  	            var nBitsLeft = data.sigBytes * 8;
 11260  
 11261  	            // Add padding
 11262  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11263  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11264  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11265  	            data.sigBytes = dataWords.length * 4;
 11266  
 11267  	            // Hash final blocks
 11268  	            this._process();
 11269  
 11270  	            // Return final computed hash
 11271  	            return this._hash;
 11272  	        },
 11273  
 11274  	        clone: function () {
 11275  	            var clone = Hasher.clone.call(this);
 11276  	            clone._hash = this._hash.clone();
 11277  
 11278  	            return clone;
 11279  	        }
 11280  	    });
 11281  
 11282  	    /**
 11283  	     * Shortcut function to the hasher's object interface.
 11284  	     *
 11285  	     * @param {WordArray|string} message The message to hash.
 11286  	     *
 11287  	     * @return {WordArray} The hash.
 11288  	     *
 11289  	     * @static
 11290  	     *
 11291  	     * @example
 11292  	     *
 11293  	     *     var hash = CryptoJS.SHA1('message');
 11294  	     *     var hash = CryptoJS.SHA1(wordArray);
 11295  	     */
 11296  	    C.SHA1 = Hasher._createHelper(SHA1);
 11297  
 11298  	    /**
 11299  	     * Shortcut function to the HMAC's object interface.
 11300  	     *
 11301  	     * @param {WordArray|string} message The message to hash.
 11302  	     * @param {WordArray|string} key The secret key.
 11303  	     *
 11304  	     * @return {WordArray} The HMAC.
 11305  	     *
 11306  	     * @static
 11307  	     *
 11308  	     * @example
 11309  	     *
 11310  	     *     var hmac = CryptoJS.HmacSHA1(message, key);
 11311  	     */
 11312  	    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
 11313  	}());
 11314  
 11315  
 11316  	return CryptoJS.SHA1;
 11317  
 11318  }));
 11319  },{"./core":53}],78:[function(require,module,exports){
 11320  ;(function (root, factory, undef) {
 11321  	if (typeof exports === "object") {
 11322  		// CommonJS
 11323  		module.exports = exports = factory(require("./core"), require("./sha256"));
 11324  	}
 11325  	else if (typeof define === "function" && define.amd) {
 11326  		// AMD
 11327  		define(["./core", "./sha256"], factory);
 11328  	}
 11329  	else {
 11330  		// Global (browser)
 11331  		factory(root.CryptoJS);
 11332  	}
 11333  }(this, function (CryptoJS) {
 11334  
 11335  	(function () {
 11336  	    // Shortcuts
 11337  	    var C = CryptoJS;
 11338  	    var C_lib = C.lib;
 11339  	    var WordArray = C_lib.WordArray;
 11340  	    var C_algo = C.algo;
 11341  	    var SHA256 = C_algo.SHA256;
 11342  
 11343  	    /**
 11344  	     * SHA-224 hash algorithm.
 11345  	     */
 11346  	    var SHA224 = C_algo.SHA224 = SHA256.extend({
 11347  	        _doReset: function () {
 11348  	            this._hash = new WordArray.init([
 11349  	                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
 11350  	                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 11351  	            ]);
 11352  	        },
 11353  
 11354  	        _doFinalize: function () {
 11355  	            var hash = SHA256._doFinalize.call(this);
 11356  
 11357  	            hash.sigBytes -= 4;
 11358  
 11359  	            return hash;
 11360  	        }
 11361  	    });
 11362  
 11363  	    /**
 11364  	     * Shortcut function to the hasher's object interface.
 11365  	     *
 11366  	     * @param {WordArray|string} message The message to hash.
 11367  	     *
 11368  	     * @return {WordArray} The hash.
 11369  	     *
 11370  	     * @static
 11371  	     *
 11372  	     * @example
 11373  	     *
 11374  	     *     var hash = CryptoJS.SHA224('message');
 11375  	     *     var hash = CryptoJS.SHA224(wordArray);
 11376  	     */
 11377  	    C.SHA224 = SHA256._createHelper(SHA224);
 11378  
 11379  	    /**
 11380  	     * Shortcut function to the HMAC's object interface.
 11381  	     *
 11382  	     * @param {WordArray|string} message The message to hash.
 11383  	     * @param {WordArray|string} key The secret key.
 11384  	     *
 11385  	     * @return {WordArray} The HMAC.
 11386  	     *
 11387  	     * @static
 11388  	     *
 11389  	     * @example
 11390  	     *
 11391  	     *     var hmac = CryptoJS.HmacSHA224(message, key);
 11392  	     */
 11393  	    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
 11394  	}());
 11395  
 11396  
 11397  	return CryptoJS.SHA224;
 11398  
 11399  }));
 11400  },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
 11401  ;(function (root, factory) {
 11402  	if (typeof exports === "object") {
 11403  		// CommonJS
 11404  		module.exports = exports = factory(require("./core"));
 11405  	}
 11406  	else if (typeof define === "function" && define.amd) {
 11407  		// AMD
 11408  		define(["./core"], factory);
 11409  	}
 11410  	else {
 11411  		// Global (browser)
 11412  		factory(root.CryptoJS);
 11413  	}
 11414  }(this, function (CryptoJS) {
 11415  
 11416  	(function (Math) {
 11417  	    // Shortcuts
 11418  	    var C = CryptoJS;
 11419  	    var C_lib = C.lib;
 11420  	    var WordArray = C_lib.WordArray;
 11421  	    var Hasher = C_lib.Hasher;
 11422  	    var C_algo = C.algo;
 11423  
 11424  	    // Initialization and round constants tables
 11425  	    var H = [];
 11426  	    var K = [];
 11427  
 11428  	    // Compute constants
 11429  	    (function () {
 11430  	        function isPrime(n) {
 11431  	            var sqrtN = Math.sqrt(n);
 11432  	            for (var factor = 2; factor <= sqrtN; factor++) {
 11433  	                if (!(n % factor)) {
 11434  	                    return false;
 11435  	                }
 11436  	            }
 11437  
 11438  	            return true;
 11439  	        }
 11440  
 11441  	        function getFractionalBits(n) {
 11442  	            return ((n - (n | 0)) * 0x100000000) | 0;
 11443  	        }
 11444  
 11445  	        var n = 2;
 11446  	        var nPrime = 0;
 11447  	        while (nPrime < 64) {
 11448  	            if (isPrime(n)) {
 11449  	                if (nPrime < 8) {
 11450  	                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
 11451  	                }
 11452  	                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
 11453  
 11454  	                nPrime++;
 11455  	            }
 11456  
 11457  	            n++;
 11458  	        }
 11459  	    }());
 11460  
 11461  	    // Reusable object
 11462  	    var W = [];
 11463  
 11464  	    /**
 11465  	     * SHA-256 hash algorithm.
 11466  	     */
 11467  	    var SHA256 = C_algo.SHA256 = Hasher.extend({
 11468  	        _doReset: function () {
 11469  	            this._hash = new WordArray.init(H.slice(0));
 11470  	        },
 11471  
 11472  	        _doProcessBlock: function (M, offset) {
 11473  	            // Shortcut
 11474  	            var H = this._hash.words;
 11475  
 11476  	            // Working variables
 11477  	            var a = H[0];
 11478  	            var b = H[1];
 11479  	            var c = H[2];
 11480  	            var d = H[3];
 11481  	            var e = H[4];
 11482  	            var f = H[5];
 11483  	            var g = H[6];
 11484  	            var h = H[7];
 11485  
 11486  	            // Computation
 11487  	            for (var i = 0; i < 64; i++) {
 11488  	                if (i < 16) {
 11489  	                    W[i] = M[offset + i] | 0;
 11490  	                } else {
 11491  	                    var gamma0x = W[i - 15];
 11492  	                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
 11493  	                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
 11494  	                                   (gamma0x >>> 3);
 11495  
 11496  	                    var gamma1x = W[i - 2];
 11497  	                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
 11498  	                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
 11499  	                                   (gamma1x >>> 10);
 11500  
 11501  	                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
 11502  	                }
 11503  
 11504  	                var ch  = (e & f) ^ (~e & g);
 11505  	                var maj = (a & b) ^ (a & c) ^ (b & c);
 11506  
 11507  	                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
 11508  	                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
 11509  
 11510  	                var t1 = h + sigma1 + ch + K[i] + W[i];
 11511  	                var t2 = sigma0 + maj;
 11512  
 11513  	                h = g;
 11514  	                g = f;
 11515  	                f = e;
 11516  	                e = (d + t1) | 0;
 11517  	                d = c;
 11518  	                c = b;
 11519  	                b = a;
 11520  	                a = (t1 + t2) | 0;
 11521  	            }
 11522  
 11523  	            // Intermediate hash value
 11524  	            H[0] = (H[0] + a) | 0;
 11525  	            H[1] = (H[1] + b) | 0;
 11526  	            H[2] = (H[2] + c) | 0;
 11527  	            H[3] = (H[3] + d) | 0;
 11528  	            H[4] = (H[4] + e) | 0;
 11529  	            H[5] = (H[5] + f) | 0;
 11530  	            H[6] = (H[6] + g) | 0;
 11531  	            H[7] = (H[7] + h) | 0;
 11532  	        },
 11533  
 11534  	        _doFinalize: function () {
 11535  	            // Shortcuts
 11536  	            var data = this._data;
 11537  	            var dataWords = data.words;
 11538  
 11539  	            var nBitsTotal = this._nDataBytes * 8;
 11540  	            var nBitsLeft = data.sigBytes * 8;
 11541  
 11542  	            // Add padding
 11543  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11544  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11545  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11546  	            data.sigBytes = dataWords.length * 4;
 11547  
 11548  	            // Hash final blocks
 11549  	            this._process();
 11550  
 11551  	            // Return final computed hash
 11552  	            return this._hash;
 11553  	        },
 11554  
 11555  	        clone: function () {
 11556  	            var clone = Hasher.clone.call(this);
 11557  	            clone._hash = this._hash.clone();
 11558  
 11559  	            return clone;
 11560  	        }
 11561  	    });
 11562  
 11563  	    /**
 11564  	     * Shortcut function to the hasher's object interface.
 11565  	     *
 11566  	     * @param {WordArray|string} message The message to hash.
 11567  	     *
 11568  	     * @return {WordArray} The hash.
 11569  	     *
 11570  	     * @static
 11571  	     *
 11572  	     * @example
 11573  	     *
 11574  	     *     var hash = CryptoJS.SHA256('message');
 11575  	     *     var hash = CryptoJS.SHA256(wordArray);
 11576  	     */
 11577  	    C.SHA256 = Hasher._createHelper(SHA256);
 11578  
 11579  	    /**
 11580  	     * Shortcut function to the HMAC's object interface.
 11581  	     *
 11582  	     * @param {WordArray|string} message The message to hash.
 11583  	     * @param {WordArray|string} key The secret key.
 11584  	     *
 11585  	     * @return {WordArray} The HMAC.
 11586  	     *
 11587  	     * @static
 11588  	     *
 11589  	     * @example
 11590  	     *
 11591  	     *     var hmac = CryptoJS.HmacSHA256(message, key);
 11592  	     */
 11593  	    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
 11594  	}(Math));
 11595  
 11596  
 11597  	return CryptoJS.SHA256;
 11598  
 11599  }));
 11600  },{"./core":53}],80:[function(require,module,exports){
 11601  ;(function (root, factory, undef) {
 11602  	if (typeof exports === "object") {
 11603  		// CommonJS
 11604  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11605  	}
 11606  	else if (typeof define === "function" && define.amd) {
 11607  		// AMD
 11608  		define(["./core", "./x64-core"], factory);
 11609  	}
 11610  	else {
 11611  		// Global (browser)
 11612  		factory(root.CryptoJS);
 11613  	}
 11614  }(this, function (CryptoJS) {
 11615  
 11616  	(function (Math) {
 11617  	    // Shortcuts
 11618  	    var C = CryptoJS;
 11619  	    var C_lib = C.lib;
 11620  	    var WordArray = C_lib.WordArray;
 11621  	    var Hasher = C_lib.Hasher;
 11622  	    var C_x64 = C.x64;
 11623  	    var X64Word = C_x64.Word;
 11624  	    var C_algo = C.algo;
 11625  
 11626  	    // Constants tables
 11627  	    var RHO_OFFSETS = [];
 11628  	    var PI_INDEXES  = [];
 11629  	    var ROUND_CONSTANTS = [];
 11630  
 11631  	    // Compute Constants
 11632  	    (function () {
 11633  	        // Compute rho offset constants
 11634  	        var x = 1, y = 0;
 11635  	        for (var t = 0; t < 24; t++) {
 11636  	            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
 11637  
 11638  	            var newX = y % 5;
 11639  	            var newY = (2 * x + 3 * y) % 5;
 11640  	            x = newX;
 11641  	            y = newY;
 11642  	        }
 11643  
 11644  	        // Compute pi index constants
 11645  	        for (var x = 0; x < 5; x++) {
 11646  	            for (var y = 0; y < 5; y++) {
 11647  	                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
 11648  	            }
 11649  	        }
 11650  
 11651  	        // Compute round constants
 11652  	        var LFSR = 0x01;
 11653  	        for (var i = 0; i < 24; i++) {
 11654  	            var roundConstantMsw = 0;
 11655  	            var roundConstantLsw = 0;
 11656  
 11657  	            for (var j = 0; j < 7; j++) {
 11658  	                if (LFSR & 0x01) {
 11659  	                    var bitPosition = (1 << j) - 1;
 11660  	                    if (bitPosition < 32) {
 11661  	                        roundConstantLsw ^= 1 << bitPosition;
 11662  	                    } else /* if (bitPosition >= 32) */ {
 11663  	                        roundConstantMsw ^= 1 << (bitPosition - 32);
 11664  	                    }
 11665  	                }
 11666  
 11667  	                // Compute next LFSR
 11668  	                if (LFSR & 0x80) {
 11669  	                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
 11670  	                    LFSR = (LFSR << 1) ^ 0x71;
 11671  	                } else {
 11672  	                    LFSR <<= 1;
 11673  	                }
 11674  	            }
 11675  
 11676  	            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
 11677  	        }
 11678  	    }());
 11679  
 11680  	    // Reusable objects for temporary values
 11681  	    var T = [];
 11682  	    (function () {
 11683  	        for (var i = 0; i < 25; i++) {
 11684  	            T[i] = X64Word.create();
 11685  	        }
 11686  	    }());
 11687  
 11688  	    /**
 11689  	     * SHA-3 hash algorithm.
 11690  	     */
 11691  	    var SHA3 = C_algo.SHA3 = Hasher.extend({
 11692  	        /**
 11693  	         * Configuration options.
 11694  	         *
 11695  	         * @property {number} outputLength
 11696  	         *   The desired number of bits in the output hash.
 11697  	         *   Only values permitted are: 224, 256, 384, 512.
 11698  	         *   Default: 512
 11699  	         */
 11700  	        cfg: Hasher.cfg.extend({
 11701  	            outputLength: 512
 11702  	        }),
 11703  
 11704  	        _doReset: function () {
 11705  	            var state = this._state = []
 11706  	            for (var i = 0; i < 25; i++) {
 11707  	                state[i] = new X64Word.init();
 11708  	            }
 11709  
 11710  	            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
 11711  	        },
 11712  
 11713  	        _doProcessBlock: function (M, offset) {
 11714  	            // Shortcuts
 11715  	            var state = this._state;
 11716  	            var nBlockSizeLanes = this.blockSize / 2;
 11717  
 11718  	            // Absorb
 11719  	            for (var i = 0; i < nBlockSizeLanes; i++) {
 11720  	                // Shortcuts
 11721  	                var M2i  = M[offset + 2 * i];
 11722  	                var M2i1 = M[offset + 2 * i + 1];
 11723  
 11724  	                // Swap endian
 11725  	                M2i = (
 11726  	                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
 11727  	                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
 11728  	                );
 11729  	                M2i1 = (
 11730  	                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
 11731  	                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
 11732  	                );
 11733  
 11734  	                // Absorb message into state
 11735  	                var lane = state[i];
 11736  	                lane.high ^= M2i1;
 11737  	                lane.low  ^= M2i;
 11738  	            }
 11739  
 11740  	            // Rounds
 11741  	            for (var round = 0; round < 24; round++) {
 11742  	                // Theta
 11743  	                for (var x = 0; x < 5; x++) {
 11744  	                    // Mix column lanes
 11745  	                    var tMsw = 0, tLsw = 0;
 11746  	                    for (var y = 0; y < 5; y++) {
 11747  	                        var lane = state[x + 5 * y];
 11748  	                        tMsw ^= lane.high;
 11749  	                        tLsw ^= lane.low;
 11750  	                    }
 11751  
 11752  	                    // Temporary values
 11753  	                    var Tx = T[x];
 11754  	                    Tx.high = tMsw;
 11755  	                    Tx.low  = tLsw;
 11756  	                }
 11757  	                for (var x = 0; x < 5; x++) {
 11758  	                    // Shortcuts
 11759  	                    var Tx4 = T[(x + 4) % 5];
 11760  	                    var Tx1 = T[(x + 1) % 5];
 11761  	                    var Tx1Msw = Tx1.high;
 11762  	                    var Tx1Lsw = Tx1.low;
 11763  
 11764  	                    // Mix surrounding columns
 11765  	                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
 11766  	                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
 11767  	                    for (var y = 0; y < 5; y++) {
 11768  	                        var lane = state[x + 5 * y];
 11769  	                        lane.high ^= tMsw;
 11770  	                        lane.low  ^= tLsw;
 11771  	                    }
 11772  	                }
 11773  
 11774  	                // Rho Pi
 11775  	                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
 11776  	                    // Shortcuts
 11777  	                    var lane = state[laneIndex];
 11778  	                    var laneMsw = lane.high;
 11779  	                    var laneLsw = lane.low;
 11780  	                    var rhoOffset = RHO_OFFSETS[laneIndex];
 11781  
 11782  	                    // Rotate lanes
 11783  	                    if (rhoOffset < 32) {
 11784  	                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
 11785  	                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
 11786  	                    } else /* if (rhoOffset >= 32) */ {
 11787  	                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
 11788  	                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
 11789  	                    }
 11790  
 11791  	                    // Transpose lanes
 11792  	                    var TPiLane = T[PI_INDEXES[laneIndex]];
 11793  	                    TPiLane.high = tMsw;
 11794  	                    TPiLane.low  = tLsw;
 11795  	                }
 11796  
 11797  	                // Rho pi at x = y = 0
 11798  	                var T0 = T[0];
 11799  	                var state0 = state[0];
 11800  	                T0.high = state0.high;
 11801  	                T0.low  = state0.low;
 11802  
 11803  	                // Chi
 11804  	                for (var x = 0; x < 5; x++) {
 11805  	                    for (var y = 0; y < 5; y++) {
 11806  	                        // Shortcuts
 11807  	                        var laneIndex = x + 5 * y;
 11808  	                        var lane = state[laneIndex];
 11809  	                        var TLane = T[laneIndex];
 11810  	                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
 11811  	                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];
 11812  
 11813  	                        // Mix rows
 11814  	                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
 11815  	                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
 11816  	                    }
 11817  	                }
 11818  
 11819  	                // Iota
 11820  	                var lane = state[0];
 11821  	                var roundConstant = ROUND_CONSTANTS[round];
 11822  	                lane.high ^= roundConstant.high;
 11823  	                lane.low  ^= roundConstant.low;;
 11824  	            }
 11825  	        },
 11826  
 11827  	        _doFinalize: function () {
 11828  	            // Shortcuts
 11829  	            var data = this._data;
 11830  	            var dataWords = data.words;
 11831  	            var nBitsTotal = this._nDataBytes * 8;
 11832  	            var nBitsLeft = data.sigBytes * 8;
 11833  	            var blockSizeBits = this.blockSize * 32;
 11834  
 11835  	            // Add padding
 11836  	            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
 11837  	            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
 11838  	            data.sigBytes = dataWords.length * 4;
 11839  
 11840  	            // Hash final blocks
 11841  	            this._process();
 11842  
 11843  	            // Shortcuts
 11844  	            var state = this._state;
 11845  	            var outputLengthBytes = this.cfg.outputLength / 8;
 11846  	            var outputLengthLanes = outputLengthBytes / 8;
 11847  
 11848  	            // Squeeze
 11849  	            var hashWords = [];
 11850  	            for (var i = 0; i < outputLengthLanes; i++) {
 11851  	                // Shortcuts
 11852  	                var lane = state[i];
 11853  	                var laneMsw = lane.high;
 11854  	                var laneLsw = lane.low;
 11855  
 11856  	                // Swap endian
 11857  	                laneMsw = (
 11858  	                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
 11859  	                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
 11860  	                );
 11861  	                laneLsw = (
 11862  	                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
 11863  	                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
 11864  	                );
 11865  
 11866  	                // Squeeze state to retrieve hash
 11867  	                hashWords.push(laneLsw);
 11868  	                hashWords.push(laneMsw);
 11869  	            }
 11870  
 11871  	            // Return final computed hash
 11872  	            return new WordArray.init(hashWords, outputLengthBytes);
 11873  	        },
 11874  
 11875  	        clone: function () {
 11876  	            var clone = Hasher.clone.call(this);
 11877  
 11878  	            var state = clone._state = this._state.slice(0);
 11879  	            for (var i = 0; i < 25; i++) {
 11880  	                state[i] = state[i].clone();
 11881  	            }
 11882  
 11883  	            return clone;
 11884  	        }
 11885  	    });
 11886  
 11887  	    /**
 11888  	     * Shortcut function to the hasher's object interface.
 11889  	     *
 11890  	     * @param {WordArray|string} message The message to hash.
 11891  	     *
 11892  	     * @return {WordArray} The hash.
 11893  	     *
 11894  	     * @static
 11895  	     *
 11896  	     * @example
 11897  	     *
 11898  	     *     var hash = CryptoJS.SHA3('message');
 11899  	     *     var hash = CryptoJS.SHA3(wordArray);
 11900  	     */
 11901  	    C.SHA3 = Hasher._createHelper(SHA3);
 11902  
 11903  	    /**
 11904  	     * Shortcut function to the HMAC's object interface.
 11905  	     *
 11906  	     * @param {WordArray|string} message The message to hash.
 11907  	     * @param {WordArray|string} key The secret key.
 11908  	     *
 11909  	     * @return {WordArray} The HMAC.
 11910  	     *
 11911  	     * @static
 11912  	     *
 11913  	     * @example
 11914  	     *
 11915  	     *     var hmac = CryptoJS.HmacSHA3(message, key);
 11916  	     */
 11917  	    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
 11918  	}(Math));
 11919  
 11920  
 11921  	return CryptoJS.SHA3;
 11922  
 11923  }));
 11924  },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
 11925  ;(function (root, factory, undef) {
 11926  	if (typeof exports === "object") {
 11927  		// CommonJS
 11928  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
 11929  	}
 11930  	else if (typeof define === "function" && define.amd) {
 11931  		// AMD
 11932  		define(["./core", "./x64-core", "./sha512"], factory);
 11933  	}
 11934  	else {
 11935  		// Global (browser)
 11936  		factory(root.CryptoJS);
 11937  	}
 11938  }(this, function (CryptoJS) {
 11939  
 11940  	(function () {
 11941  	    // Shortcuts
 11942  	    var C = CryptoJS;
 11943  	    var C_x64 = C.x64;
 11944  	    var X64Word = C_x64.Word;
 11945  	    var X64WordArray = C_x64.WordArray;
 11946  	    var C_algo = C.algo;
 11947  	    var SHA512 = C_algo.SHA512;
 11948  
 11949  	    /**
 11950  	     * SHA-384 hash algorithm.
 11951  	     */
 11952  	    var SHA384 = C_algo.SHA384 = SHA512.extend({
 11953  	        _doReset: function () {
 11954  	            this._hash = new X64WordArray.init([
 11955  	                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
 11956  	                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
 11957  	                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
 11958  	                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
 11959  	            ]);
 11960  	        },
 11961  
 11962  	        _doFinalize: function () {
 11963  	            var hash = SHA512._doFinalize.call(this);
 11964  
 11965  	            hash.sigBytes -= 16;
 11966  
 11967  	            return hash;
 11968  	        }
 11969  	    });
 11970  
 11971  	    /**
 11972  	     * Shortcut function to the hasher's object interface.
 11973  	     *
 11974  	     * @param {WordArray|string} message The message to hash.
 11975  	     *
 11976  	     * @return {WordArray} The hash.
 11977  	     *
 11978  	     * @static
 11979  	     *
 11980  	     * @example
 11981  	     *
 11982  	     *     var hash = CryptoJS.SHA384('message');
 11983  	     *     var hash = CryptoJS.SHA384(wordArray);
 11984  	     */
 11985  	    C.SHA384 = SHA512._createHelper(SHA384);
 11986  
 11987  	    /**
 11988  	     * Shortcut function to the HMAC's object interface.
 11989  	     *
 11990  	     * @param {WordArray|string} message The message to hash.
 11991  	     * @param {WordArray|string} key The secret key.
 11992  	     *
 11993  	     * @return {WordArray} The HMAC.
 11994  	     *
 11995  	     * @static
 11996  	     *
 11997  	     * @example
 11998  	     *
 11999  	     *     var hmac = CryptoJS.HmacSHA384(message, key);
 12000  	     */
 12001  	    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
 12002  	}());
 12003  
 12004  
 12005  	return CryptoJS.SHA384;
 12006  
 12007  }));
 12008  },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
 12009  ;(function (root, factory, undef) {
 12010  	if (typeof exports === "object") {
 12011  		// CommonJS
 12012  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 12013  	}
 12014  	else if (typeof define === "function" && define.amd) {
 12015  		// AMD
 12016  		define(["./core", "./x64-core"], factory);
 12017  	}
 12018  	else {
 12019  		// Global (browser)
 12020  		factory(root.CryptoJS);
 12021  	}
 12022  }(this, function (CryptoJS) {
 12023  
 12024  	(function () {
 12025  	    // Shortcuts
 12026  	    var C = CryptoJS;
 12027  	    var C_lib = C.lib;
 12028  	    var Hasher = C_lib.Hasher;
 12029  	    var C_x64 = C.x64;
 12030  	    var X64Word = C_x64.Word;
 12031  	    var X64WordArray = C_x64.WordArray;
 12032  	    var C_algo = C.algo;
 12033  
 12034  	    function X64Word_create() {
 12035  	        return X64Word.create.apply(X64Word, arguments);
 12036  	    }
 12037  
 12038  	    // Constants
 12039  	    var K = [
 12040  	        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
 12041  	        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
 12042  	        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
 12043  	        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
 12044  	        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
 12045  	        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
 12046  	        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
 12047  	        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
 12048  	        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
 12049  	        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
 12050  	        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
 12051  	        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
 12052  	        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
 12053  	        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
 12054  	        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
 12055  	        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
 12056  	        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
 12057  	        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
 12058  	        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
 12059  	        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
 12060  	        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
 12061  	        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
 12062  	        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
 12063  	        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
 12064  	        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
 12065  	        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
 12066  	        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
 12067  	        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
 12068  	        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
 12069  	        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
 12070  	        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
 12071  	        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
 12072  	        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
 12073  	        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
 12074  	        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
 12075  	        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
 12076  	        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
 12077  	        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
 12078  	        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
 12079  	        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
 12080  	    ];
 12081  
 12082  	    // Reusable objects
 12083  	    var W = [];
 12084  	    (function () {
 12085  	        for (var i = 0; i < 80; i++) {
 12086  	            W[i] = X64Word_create();
 12087  	        }
 12088  	    }());
 12089  
 12090  	    /**
 12091  	     * SHA-512 hash algorithm.
 12092  	     */
 12093  	    var SHA512 = C_algo.SHA512 = Hasher.extend({
 12094  	        _doReset: function () {
 12095  	            this._hash = new X64WordArray.init([
 12096  	                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
 12097  	                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
 12098  	                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
 12099  	                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
 12100  	            ]);
 12101  	        },
 12102  
 12103  	        _doProcessBlock: function (M, offset) {
 12104  	            // Shortcuts
 12105  	            var H = this._hash.words;
 12106  
 12107  	            var H0 = H[0];
 12108  	            var H1 = H[1];
 12109  	            var H2 = H[2];
 12110  	            var H3 = H[3];
 12111  	            var H4 = H[4];
 12112  	            var H5 = H[5];
 12113  	            var H6 = H[6];
 12114  	            var H7 = H[7];
 12115  
 12116  	            var H0h = H0.high;
 12117  	            var H0l = H0.low;
 12118  	            var H1h = H1.high;
 12119  	            var H1l = H1.low;
 12120  	            var H2h = H2.high;
 12121  	            var H2l = H2.low;
 12122  	            var H3h = H3.high;
 12123  	            var H3l = H3.low;
 12124  	            var H4h = H4.high;
 12125  	            var H4l = H4.low;
 12126  	            var H5h = H5.high;
 12127  	            var H5l = H5.low;
 12128  	            var H6h = H6.high;
 12129  	            var H6l = H6.low;
 12130  	            var H7h = H7.high;
 12131  	            var H7l = H7.low;
 12132  
 12133  	            // Working variables
 12134  	            var ah = H0h;
 12135  	            var al = H0l;
 12136  	            var bh = H1h;
 12137  	            var bl = H1l;
 12138  	            var ch = H2h;
 12139  	            var cl = H2l;
 12140  	            var dh = H3h;
 12141  	            var dl = H3l;
 12142  	            var eh = H4h;
 12143  	            var el = H4l;
 12144  	            var fh = H5h;
 12145  	            var fl = H5l;
 12146  	            var gh = H6h;
 12147  	            var gl = H6l;
 12148  	            var hh = H7h;
 12149  	            var hl = H7l;
 12150  
 12151  	            // Rounds
 12152  	            for (var i = 0; i < 80; i++) {
 12153  	                // Shortcut
 12154  	                var Wi = W[i];
 12155  
 12156  	                // Extend message
 12157  	                if (i < 16) {
 12158  	                    var Wih = Wi.high = M[offset + i * 2]     | 0;
 12159  	                    var Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
 12160  	                } else {
 12161  	                    // Gamma0
 12162  	                    var gamma0x  = W[i - 15];
 12163  	                    var gamma0xh = gamma0x.high;
 12164  	                    var gamma0xl = gamma0x.low;
 12165  	                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
 12166  	                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
 12167  
 12168  	                    // Gamma1
 12169  	                    var gamma1x  = W[i - 2];
 12170  	                    var gamma1xh = gamma1x.high;
 12171  	                    var gamma1xl = gamma1x.low;
 12172  	                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
 12173  	                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
 12174  
 12175  	                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
 12176  	                    var Wi7  = W[i - 7];
 12177  	                    var Wi7h = Wi7.high;
 12178  	                    var Wi7l = Wi7.low;
 12179  
 12180  	                    var Wi16  = W[i - 16];
 12181  	                    var Wi16h = Wi16.high;
 12182  	                    var Wi16l = Wi16.low;
 12183  
 12184  	                    var Wil = gamma0l + Wi7l;
 12185  	                    var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
 12186  	                    var Wil = Wil + gamma1l;
 12187  	                    var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
 12188  	                    var Wil = Wil + Wi16l;
 12189  	                    var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
 12190  
 12191  	                    Wi.high = Wih;
 12192  	                    Wi.low  = Wil;
 12193  	                }
 12194  
 12195  	                var chh  = (eh & fh) ^ (~eh & gh);
 12196  	                var chl  = (el & fl) ^ (~el & gl);
 12197  	                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
 12198  	                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
 12199  
 12200  	                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
 12201  	                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
 12202  	                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
 12203  	                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
 12204  
 12205  	                // t1 = h + sigma1 + ch + K[i] + W[i]
 12206  	                var Ki  = K[i];
 12207  	                var Kih = Ki.high;
 12208  	                var Kil = Ki.low;
 12209  
 12210  	                var t1l = hl + sigma1l;
 12211  	                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
 12212  	                var t1l = t1l + chl;
 12213  	                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
 12214  	                var t1l = t1l + Kil;
 12215  	                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
 12216  	                var t1l = t1l + Wil;
 12217  	                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
 12218  
 12219  	                // t2 = sigma0 + maj
 12220  	                var t2l = sigma0l + majl;
 12221  	                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
 12222  
 12223  	                // Update working variables
 12224  	                hh = gh;
 12225  	                hl = gl;
 12226  	                gh = fh;
 12227  	                gl = fl;
 12228  	                fh = eh;
 12229  	                fl = el;
 12230  	                el = (dl + t1l) | 0;
 12231  	                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
 12232  	                dh = ch;
 12233  	                dl = cl;
 12234  	                ch = bh;
 12235  	                cl = bl;
 12236  	                bh = ah;
 12237  	                bl = al;
 12238  	                al = (t1l + t2l) | 0;
 12239  	                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
 12240  	            }
 12241  
 12242  	            // Intermediate hash value
 12243  	            H0l = H0.low  = (H0l + al);
 12244  	            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
 12245  	            H1l = H1.low  = (H1l + bl);
 12246  	            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
 12247  	            H2l = H2.low  = (H2l + cl);
 12248  	            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
 12249  	            H3l = H3.low  = (H3l + dl);
 12250  	            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
 12251  	            H4l = H4.low  = (H4l + el);
 12252  	            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
 12253  	            H5l = H5.low  = (H5l + fl);
 12254  	            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
 12255  	            H6l = H6.low  = (H6l + gl);
 12256  	            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
 12257  	            H7l = H7.low  = (H7l + hl);
 12258  	            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
 12259  	        },
 12260  
 12261  	        _doFinalize: function () {
 12262  	            // Shortcuts
 12263  	            var data = this._data;
 12264  	            var dataWords = data.words;
 12265  
 12266  	            var nBitsTotal = this._nDataBytes * 8;
 12267  	            var nBitsLeft = data.sigBytes * 8;
 12268  
 12269  	            // Add padding
 12270  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 12271  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
 12272  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
 12273  	            data.sigBytes = dataWords.length * 4;
 12274  
 12275  	            // Hash final blocks
 12276  	            this._process();
 12277  
 12278  	            // Convert hash to 32-bit word array before returning
 12279  	            var hash = this._hash.toX32();
 12280  
 12281  	            // Return final computed hash
 12282  	            return hash;
 12283  	        },
 12284  
 12285  	        clone: function () {
 12286  	            var clone = Hasher.clone.call(this);
 12287  	            clone._hash = this._hash.clone();
 12288  
 12289  	            return clone;
 12290  	        },
 12291  
 12292  	        blockSize: 1024/32
 12293  	    });
 12294  
 12295  	    /**
 12296  	     * Shortcut function to the hasher's object interface.
 12297  	     *
 12298  	     * @param {WordArray|string} message The message to hash.
 12299  	     *
 12300  	     * @return {WordArray} The hash.
 12301  	     *
 12302  	     * @static
 12303  	     *
 12304  	     * @example
 12305  	     *
 12306  	     *     var hash = CryptoJS.SHA512('message');
 12307  	     *     var hash = CryptoJS.SHA512(wordArray);
 12308  	     */
 12309  	    C.SHA512 = Hasher._createHelper(SHA512);
 12310  
 12311  	    /**
 12312  	     * Shortcut function to the HMAC's object interface.
 12313  	     *
 12314  	     * @param {WordArray|string} message The message to hash.
 12315  	     * @param {WordArray|string} key The secret key.
 12316  	     *
 12317  	     * @return {WordArray} The HMAC.
 12318  	     *
 12319  	     * @static
 12320  	     *
 12321  	     * @example
 12322  	     *
 12323  	     *     var hmac = CryptoJS.HmacSHA512(message, key);
 12324  	     */
 12325  	    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
 12326  	}());
 12327  
 12328  
 12329  	return CryptoJS.SHA512;
 12330  
 12331  }));
 12332  },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
 12333  ;(function (root, factory, undef) {
 12334  	if (typeof exports === "object") {
 12335  		// CommonJS
 12336  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 12337  	}
 12338  	else if (typeof define === "function" && define.amd) {
 12339  		// AMD
 12340  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 12341  	}
 12342  	else {
 12343  		// Global (browser)
 12344  		factory(root.CryptoJS);
 12345  	}
 12346  }(this, function (CryptoJS) {
 12347  
 12348  	(function () {
 12349  	    // Shortcuts
 12350  	    var C = CryptoJS;
 12351  	    var C_lib = C.lib;
 12352  	    var WordArray = C_lib.WordArray;
 12353  	    var BlockCipher = C_lib.BlockCipher;
 12354  	    var C_algo = C.algo;
 12355  
 12356  	    // Permuted Choice 1 constants
 12357  	    var PC1 = [
 12358  	        57, 49, 41, 33, 25, 17, 9,  1,
 12359  	        58, 50, 42, 34, 26, 18, 10, 2,
 12360  	        59, 51, 43, 35, 27, 19, 11, 3,
 12361  	        60, 52, 44, 36, 63, 55, 47, 39,
 12362  	        31, 23, 15, 7,  62, 54, 46, 38,
 12363  	        30, 22, 14, 6,  61, 53, 45, 37,
 12364  	        29, 21, 13, 5,  28, 20, 12, 4
 12365  	    ];
 12366  
 12367  	    // Permuted Choice 2 constants
 12368  	    var PC2 = [
 12369  	        14, 17, 11, 24, 1,  5,
 12370  	        3,  28, 15, 6,  21, 10,
 12371  	        23, 19, 12, 4,  26, 8,
 12372  	        16, 7,  27, 20, 13, 2,
 12373  	        41, 52, 31, 37, 47, 55,
 12374  	        30, 40, 51, 45, 33, 48,
 12375  	        44, 49, 39, 56, 34, 53,
 12376  	        46, 42, 50, 36, 29, 32
 12377  	    ];
 12378  
 12379  	    // Cumulative bit shift constants
 12380  	    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
 12381  
 12382  	    // SBOXes and round permutation constants
 12383  	    var SBOX_P = [
 12384  	        {
 12385  	            0x0: 0x808200,
 12386  	            0x10000000: 0x8000,
 12387  	            0x20000000: 0x808002,
 12388  	            0x30000000: 0x2,
 12389  	            0x40000000: 0x200,
 12390  	            0x50000000: 0x808202,
 12391  	            0x60000000: 0x800202,
 12392  	            0x70000000: 0x800000,
 12393  	            0x80000000: 0x202,
 12394  	            0x90000000: 0x800200,
 12395  	            0xa0000000: 0x8200,
 12396  	            0xb0000000: 0x808000,
 12397  	            0xc0000000: 0x8002,
 12398  	            0xd0000000: 0x800002,
 12399  	            0xe0000000: 0x0,
 12400  	            0xf0000000: 0x8202,
 12401  	            0x8000000: 0x0,
 12402  	            0x18000000: 0x808202,
 12403  	            0x28000000: 0x8202,
 12404  	            0x38000000: 0x8000,
 12405  	            0x48000000: 0x808200,
 12406  	            0x58000000: 0x200,
 12407  	            0x68000000: 0x808002,
 12408  	            0x78000000: 0x2,
 12409  	            0x88000000: 0x800200,
 12410  	            0x98000000: 0x8200,
 12411  	            0xa8000000: 0x808000,
 12412  	            0xb8000000: 0x800202,
 12413  	            0xc8000000: 0x800002,
 12414  	            0xd8000000: 0x8002,
 12415  	            0xe8000000: 0x202,
 12416  	            0xf8000000: 0x800000,
 12417  	            0x1: 0x8000,
 12418  	            0x10000001: 0x2,
 12419  	            0x20000001: 0x808200,
 12420  	            0x30000001: 0x800000,
 12421  	            0x40000001: 0x808002,
 12422  	            0x50000001: 0x8200,
 12423  	            0x60000001: 0x200,
 12424  	            0x70000001: 0x800202,
 12425  	            0x80000001: 0x808202,
 12426  	            0x90000001: 0x808000,
 12427  	            0xa0000001: 0x800002,
 12428  	            0xb0000001: 0x8202,
 12429  	            0xc0000001: 0x202,
 12430  	            0xd0000001: 0x800200,
 12431  	            0xe0000001: 0x8002,
 12432  	            0xf0000001: 0x0,
 12433  	            0x8000001: 0x808202,
 12434  	            0x18000001: 0x808000,
 12435  	            0x28000001: 0x800000,
 12436  	            0x38000001: 0x200,
 12437  	            0x48000001: 0x8000,
 12438  	            0x58000001: 0x800002,
 12439  	            0x68000001: 0x2,
 12440  	            0x78000001: 0x8202,
 12441  	            0x88000001: 0x8002,
 12442  	            0x98000001: 0x800202,
 12443  	            0xa8000001: 0x202,
 12444  	            0xb8000001: 0x808200,
 12445  	            0xc8000001: 0x800200,
 12446  	            0xd8000001: 0x0,
 12447  	            0xe8000001: 0x8200,
 12448  	            0xf8000001: 0x808002
 12449  	        },
 12450  	        {
 12451  	            0x0: 0x40084010,
 12452  	            0x1000000: 0x4000,
 12453  	            0x2000000: 0x80000,
 12454  	            0x3000000: 0x40080010,
 12455  	            0x4000000: 0x40000010,
 12456  	            0x5000000: 0x40084000,
 12457  	            0x6000000: 0x40004000,
 12458  	            0x7000000: 0x10,
 12459  	            0x8000000: 0x84000,
 12460  	            0x9000000: 0x40004010,
 12461  	            0xa000000: 0x40000000,
 12462  	            0xb000000: 0x84010,
 12463  	            0xc000000: 0x80010,
 12464  	            0xd000000: 0x0,
 12465  	            0xe000000: 0x4010,
 12466  	            0xf000000: 0x40080000,
 12467  	            0x800000: 0x40004000,
 12468  	            0x1800000: 0x84010,
 12469  	            0x2800000: 0x10,
 12470  	            0x3800000: 0x40004010,
 12471  	            0x4800000: 0x40084010,
 12472  	            0x5800000: 0x40000000,
 12473  	            0x6800000: 0x80000,
 12474  	            0x7800000: 0x40080010,
 12475  	            0x8800000: 0x80010,
 12476  	            0x9800000: 0x0,
 12477  	            0xa800000: 0x4000,
 12478  	            0xb800000: 0x40080000,
 12479  	            0xc800000: 0x40000010,
 12480  	            0xd800000: 0x84000,
 12481  	            0xe800000: 0x40084000,
 12482  	            0xf800000: 0x4010,
 12483  	            0x10000000: 0x0,
 12484  	            0x11000000: 0x40080010,
 12485  	            0x12000000: 0x40004010,
 12486  	            0x13000000: 0x40084000,
 12487  	            0x14000000: 0x40080000,
 12488  	            0x15000000: 0x10,
 12489  	            0x16000000: 0x84010,
 12490  	            0x17000000: 0x4000,
 12491  	            0x18000000: 0x4010,
 12492  	            0x19000000: 0x80000,
 12493  	            0x1a000000: 0x80010,
 12494  	            0x1b000000: 0x40000010,
 12495  	            0x1c000000: 0x84000,
 12496  	            0x1d000000: 0x40004000,
 12497  	            0x1e000000: 0x40000000,
 12498  	            0x1f000000: 0x40084010,
 12499  	            0x10800000: 0x84010,
 12500  	            0x11800000: 0x80000,
 12501  	            0x12800000: 0x40080000,
 12502  	            0x13800000: 0x4000,
 12503  	            0x14800000: 0x40004000,
 12504  	            0x15800000: 0x40084010,
 12505  	            0x16800000: 0x10,
 12506  	            0x17800000: 0x40000000,
 12507  	            0x18800000: 0x40084000,
 12508  	            0x19800000: 0x40000010,
 12509  	            0x1a800000: 0x40004010,
 12510  	            0x1b800000: 0x80010,
 12511  	            0x1c800000: 0x0,
 12512  	            0x1d800000: 0x4010,
 12513  	            0x1e800000: 0x40080010,
 12514  	            0x1f800000: 0x84000
 12515  	        },
 12516  	        {
 12517  	            0x0: 0x104,
 12518  	            0x100000: 0x0,
 12519  	            0x200000: 0x4000100,
 12520  	            0x300000: 0x10104,
 12521  	            0x400000: 0x10004,
 12522  	            0x500000: 0x4000004,
 12523  	            0x600000: 0x4010104,
 12524  	            0x700000: 0x4010000,
 12525  	            0x800000: 0x4000000,
 12526  	            0x900000: 0x4010100,
 12527  	            0xa00000: 0x10100,
 12528  	            0xb00000: 0x4010004,
 12529  	            0xc00000: 0x4000104,
 12530  	            0xd00000: 0x10000,
 12531  	            0xe00000: 0x4,
 12532  	            0xf00000: 0x100,
 12533  	            0x80000: 0x4010100,
 12534  	            0x180000: 0x4010004,
 12535  	            0x280000: 0x0,
 12536  	            0x380000: 0x4000100,
 12537  	            0x480000: 0x4000004,
 12538  	            0x580000: 0x10000,
 12539  	            0x680000: 0x10004,
 12540  	            0x780000: 0x104,
 12541  	            0x880000: 0x4,
 12542  	            0x980000: 0x100,
 12543  	            0xa80000: 0x4010000,
 12544  	            0xb80000: 0x10104,
 12545  	            0xc80000: 0x10100,
 12546  	            0xd80000: 0x4000104,
 12547  	            0xe80000: 0x4010104,
 12548  	            0xf80000: 0x4000000,
 12549  	            0x1000000: 0x4010100,
 12550  	            0x1100000: 0x10004,
 12551  	            0x1200000: 0x10000,
 12552  	            0x1300000: 0x4000100,
 12553  	            0x1400000: 0x100,
 12554  	            0x1500000: 0x4010104,
 12555  	            0x1600000: 0x4000004,
 12556  	            0x1700000: 0x0,
 12557  	            0x1800000: 0x4000104,
 12558  	            0x1900000: 0x4000000,
 12559  	            0x1a00000: 0x4,
 12560  	            0x1b00000: 0x10100,
 12561  	            0x1c00000: 0x4010000,
 12562  	            0x1d00000: 0x104,
 12563  	            0x1e00000: 0x10104,
 12564  	            0x1f00000: 0x4010004,
 12565  	            0x1080000: 0x4000000,
 12566  	            0x1180000: 0x104,
 12567  	            0x1280000: 0x4010100,
 12568  	            0x1380000: 0x0,
 12569  	            0x1480000: 0x10004,
 12570  	            0x1580000: 0x4000100,
 12571  	            0x1680000: 0x100,
 12572  	            0x1780000: 0x4010004,
 12573  	            0x1880000: 0x10000,
 12574  	            0x1980000: 0x4010104,
 12575  	            0x1a80000: 0x10104,
 12576  	            0x1b80000: 0x4000004,
 12577  	            0x1c80000: 0x4000104,
 12578  	            0x1d80000: 0x4010000,
 12579  	            0x1e80000: 0x4,
 12580  	            0x1f80000: 0x10100
 12581  	        },
 12582  	        {
 12583  	            0x0: 0x80401000,
 12584  	            0x10000: 0x80001040,
 12585  	            0x20000: 0x401040,
 12586  	            0x30000: 0x80400000,
 12587  	            0x40000: 0x0,
 12588  	            0x50000: 0x401000,
 12589  	            0x60000: 0x80000040,
 12590  	            0x70000: 0x400040,
 12591  	            0x80000: 0x80000000,
 12592  	            0x90000: 0x400000,
 12593  	            0xa0000: 0x40,
 12594  	            0xb0000: 0x80001000,
 12595  	            0xc0000: 0x80400040,
 12596  	            0xd0000: 0x1040,
 12597  	            0xe0000: 0x1000,
 12598  	            0xf0000: 0x80401040,
 12599  	            0x8000: 0x80001040,
 12600  	            0x18000: 0x40,
 12601  	            0x28000: 0x80400040,
 12602  	            0x38000: 0x80001000,
 12603  	            0x48000: 0x401000,
 12604  	            0x58000: 0x80401040,
 12605  	            0x68000: 0x0,
 12606  	            0x78000: 0x80400000,
 12607  	            0x88000: 0x1000,
 12608  	            0x98000: 0x80401000,
 12609  	            0xa8000: 0x400000,
 12610  	            0xb8000: 0x1040,
 12611  	            0xc8000: 0x80000000,
 12612  	            0xd8000: 0x400040,
 12613  	            0xe8000: 0x401040,
 12614  	            0xf8000: 0x80000040,
 12615  	            0x100000: 0x400040,
 12616  	            0x110000: 0x401000,
 12617  	            0x120000: 0x80000040,
 12618  	            0x130000: 0x0,
 12619  	            0x140000: 0x1040,
 12620  	            0x150000: 0x80400040,
 12621  	            0x160000: 0x80401000,
 12622  	            0x170000: 0x80001040,
 12623  	            0x180000: 0x80401040,
 12624  	            0x190000: 0x80000000,
 12625  	            0x1a0000: 0x80400000,
 12626  	            0x1b0000: 0x401040,
 12627  	            0x1c0000: 0x80001000,
 12628  	            0x1d0000: 0x400000,
 12629  	            0x1e0000: 0x40,
 12630  	            0x1f0000: 0x1000,
 12631  	            0x108000: 0x80400000,
 12632  	            0x118000: 0x80401040,
 12633  	            0x128000: 0x0,
 12634  	            0x138000: 0x401000,
 12635  	            0x148000: 0x400040,
 12636  	            0x158000: 0x80000000,
 12637  	            0x168000: 0x80001040,
 12638  	            0x178000: 0x40,
 12639  	            0x188000: 0x80000040,
 12640  	            0x198000: 0x1000,
 12641  	            0x1a8000: 0x80001000,
 12642  	            0x1b8000: 0x80400040,
 12643  	            0x1c8000: 0x1040,
 12644  	            0x1d8000: 0x80401000,
 12645  	            0x1e8000: 0x400000,
 12646  	            0x1f8000: 0x401040
 12647  	        },
 12648  	        {
 12649  	            0x0: 0x80,
 12650  	            0x1000: 0x1040000,
 12651  	            0x2000: 0x40000,
 12652  	            0x3000: 0x20000000,
 12653  	            0x4000: 0x20040080,
 12654  	            0x5000: 0x1000080,
 12655  	            0x6000: 0x21000080,
 12656  	            0x7000: 0x40080,
 12657  	            0x8000: 0x1000000,
 12658  	            0x9000: 0x20040000,
 12659  	            0xa000: 0x20000080,
 12660  	            0xb000: 0x21040080,
 12661  	            0xc000: 0x21040000,
 12662  	            0xd000: 0x0,
 12663  	            0xe000: 0x1040080,
 12664  	            0xf000: 0x21000000,
 12665  	            0x800: 0x1040080,
 12666  	            0x1800: 0x21000080,
 12667  	            0x2800: 0x80,
 12668  	            0x3800: 0x1040000,
 12669  	            0x4800: 0x40000,
 12670  	            0x5800: 0x20040080,
 12671  	            0x6800: 0x21040000,
 12672  	            0x7800: 0x20000000,
 12673  	            0x8800: 0x20040000,
 12674  	            0x9800: 0x0,
 12675  	            0xa800: 0x21040080,
 12676  	            0xb800: 0x1000080,
 12677  	            0xc800: 0x20000080,
 12678  	            0xd800: 0x21000000,
 12679  	            0xe800: 0x1000000,
 12680  	            0xf800: 0x40080,
 12681  	            0x10000: 0x40000,
 12682  	            0x11000: 0x80,
 12683  	            0x12000: 0x20000000,
 12684  	            0x13000: 0x21000080,
 12685  	            0x14000: 0x1000080,
 12686  	            0x15000: 0x21040000,
 12687  	            0x16000: 0x20040080,
 12688  	            0x17000: 0x1000000,
 12689  	            0x18000: 0x21040080,
 12690  	            0x19000: 0x21000000,
 12691  	            0x1a000: 0x1040000,
 12692  	            0x1b000: 0x20040000,
 12693  	            0x1c000: 0x40080,
 12694  	            0x1d000: 0x20000080,
 12695  	            0x1e000: 0x0,
 12696  	            0x1f000: 0x1040080,
 12697  	            0x10800: 0x21000080,
 12698  	            0x11800: 0x1000000,
 12699  	            0x12800: 0x1040000,
 12700  	            0x13800: 0x20040080,
 12701  	            0x14800: 0x20000000,
 12702  	            0x15800: 0x1040080,
 12703  	            0x16800: 0x80,
 12704  	            0x17800: 0x21040000,
 12705  	            0x18800: 0x40080,
 12706  	            0x19800: 0x21040080,
 12707  	            0x1a800: 0x0,
 12708  	            0x1b800: 0x21000000,
 12709  	            0x1c800: 0x1000080,
 12710  	            0x1d800: 0x40000,
 12711  	            0x1e800: 0x20040000,
 12712  	            0x1f800: 0x20000080
 12713  	        },
 12714  	        {
 12715  	            0x0: 0x10000008,
 12716  	            0x100: 0x2000,
 12717  	            0x200: 0x10200000,
 12718  	            0x300: 0x10202008,
 12719  	            0x400: 0x10002000,
 12720  	            0x500: 0x200000,
 12721  	            0x600: 0x200008,
 12722  	            0x700: 0x10000000,
 12723  	            0x800: 0x0,
 12724  	            0x900: 0x10002008,
 12725  	            0xa00: 0x202000,
 12726  	            0xb00: 0x8,
 12727  	            0xc00: 0x10200008,
 12728  	            0xd00: 0x202008,
 12729  	            0xe00: 0x2008,
 12730  	            0xf00: 0x10202000,
 12731  	            0x80: 0x10200000,
 12732  	            0x180: 0x10202008,
 12733  	            0x280: 0x8,
 12734  	            0x380: 0x200000,
 12735  	            0x480: 0x202008,
 12736  	            0x580: 0x10000008,
 12737  	            0x680: 0x10002000,
 12738  	            0x780: 0x2008,
 12739  	            0x880: 0x200008,
 12740  	            0x980: 0x2000,
 12741  	            0xa80: 0x10002008,
 12742  	            0xb80: 0x10200008,
 12743  	            0xc80: 0x0,
 12744  	            0xd80: 0x10202000,
 12745  	            0xe80: 0x202000,
 12746  	            0xf80: 0x10000000,
 12747  	            0x1000: 0x10002000,
 12748  	            0x1100: 0x10200008,
 12749  	            0x1200: 0x10202008,
 12750  	            0x1300: 0x2008,
 12751  	            0x1400: 0x200000,
 12752  	            0x1500: 0x10000000,
 12753  	            0x1600: 0x10000008,
 12754  	            0x1700: 0x202000,
 12755  	            0x1800: 0x202008,
 12756  	            0x1900: 0x0,
 12757  	            0x1a00: 0x8,
 12758  	            0x1b00: 0x10200000,
 12759  	            0x1c00: 0x2000,
 12760  	            0x1d00: 0x10002008,
 12761  	            0x1e00: 0x10202000,
 12762  	            0x1f00: 0x200008,
 12763  	            0x1080: 0x8,
 12764  	            0x1180: 0x202000,
 12765  	            0x1280: 0x200000,
 12766  	            0x1380: 0x10000008,
 12767  	            0x1480: 0x10002000,
 12768  	            0x1580: 0x2008,
 12769  	            0x1680: 0x10202008,
 12770  	            0x1780: 0x10200000,
 12771  	            0x1880: 0x10202000,
 12772  	            0x1980: 0x10200008,
 12773  	            0x1a80: 0x2000,
 12774  	            0x1b80: 0x202008,
 12775  	            0x1c80: 0x200008,
 12776  	            0x1d80: 0x0,
 12777  	            0x1e80: 0x10000000,
 12778  	            0x1f80: 0x10002008
 12779  	        },
 12780  	        {
 12781  	            0x0: 0x100000,
 12782  	            0x10: 0x2000401,
 12783  	            0x20: 0x400,
 12784  	            0x30: 0x100401,
 12785  	            0x40: 0x2100401,
 12786  	            0x50: 0x0,
 12787  	            0x60: 0x1,
 12788  	            0x70: 0x2100001,
 12789  	            0x80: 0x2000400,
 12790  	            0x90: 0x100001,
 12791  	            0xa0: 0x2000001,
 12792  	            0xb0: 0x2100400,
 12793  	            0xc0: 0x2100000,
 12794  	            0xd0: 0x401,
 12795  	            0xe0: 0x100400,
 12796  	            0xf0: 0x2000000,
 12797  	            0x8: 0x2100001,
 12798  	            0x18: 0x0,
 12799  	            0x28: 0x2000401,
 12800  	            0x38: 0x2100400,
 12801  	            0x48: 0x100000,
 12802  	            0x58: 0x2000001,
 12803  	            0x68: 0x2000000,
 12804  	            0x78: 0x401,
 12805  	            0x88: 0x100401,
 12806  	            0x98: 0x2000400,
 12807  	            0xa8: 0x2100000,
 12808  	            0xb8: 0x100001,
 12809  	            0xc8: 0x400,
 12810  	            0xd8: 0x2100401,
 12811  	            0xe8: 0x1,
 12812  	            0xf8: 0x100400,
 12813  	            0x100: 0x2000000,
 12814  	            0x110: 0x100000,
 12815  	            0x120: 0x2000401,
 12816  	            0x130: 0x2100001,
 12817  	            0x140: 0x100001,
 12818  	            0x150: 0x2000400,
 12819  	            0x160: 0x2100400,
 12820  	            0x170: 0x100401,
 12821  	            0x180: 0x401,
 12822  	            0x190: 0x2100401,
 12823  	            0x1a0: 0x100400,
 12824  	            0x1b0: 0x1,
 12825  	            0x1c0: 0x0,
 12826  	            0x1d0: 0x2100000,
 12827  	            0x1e0: 0x2000001,
 12828  	            0x1f0: 0x400,
 12829  	            0x108: 0x100400,
 12830  	            0x118: 0x2000401,
 12831  	            0x128: 0x2100001,
 12832  	            0x138: 0x1,
 12833  	            0x148: 0x2000000,
 12834  	            0x158: 0x100000,
 12835  	            0x168: 0x401,
 12836  	            0x178: 0x2100400,
 12837  	            0x188: 0x2000001,
 12838  	            0x198: 0x2100000,
 12839  	            0x1a8: 0x0,
 12840  	            0x1b8: 0x2100401,
 12841  	            0x1c8: 0x100401,
 12842  	            0x1d8: 0x400,
 12843  	            0x1e8: 0x2000400,
 12844  	            0x1f8: 0x100001
 12845  	        },
 12846  	        {
 12847  	            0x0: 0x8000820,
 12848  	            0x1: 0x20000,
 12849  	            0x2: 0x8000000,
 12850  	            0x3: 0x20,
 12851  	            0x4: 0x20020,
 12852  	            0x5: 0x8020820,
 12853  	            0x6: 0x8020800,
 12854  	            0x7: 0x800,
 12855  	            0x8: 0x8020000,
 12856  	            0x9: 0x8000800,
 12857  	            0xa: 0x20800,
 12858  	            0xb: 0x8020020,
 12859  	            0xc: 0x820,
 12860  	            0xd: 0x0,
 12861  	            0xe: 0x8000020,
 12862  	            0xf: 0x20820,
 12863  	            0x80000000: 0x800,
 12864  	            0x80000001: 0x8020820,
 12865  	            0x80000002: 0x8000820,
 12866  	            0x80000003: 0x8000000,
 12867  	            0x80000004: 0x8020000,
 12868  	            0x80000005: 0x20800,
 12869  	            0x80000006: 0x20820,
 12870  	            0x80000007: 0x20,
 12871  	            0x80000008: 0x8000020,
 12872  	            0x80000009: 0x820,
 12873  	            0x8000000a: 0x20020,
 12874  	            0x8000000b: 0x8020800,
 12875  	            0x8000000c: 0x0,
 12876  	            0x8000000d: 0x8020020,
 12877  	            0x8000000e: 0x8000800,
 12878  	            0x8000000f: 0x20000,
 12879  	            0x10: 0x20820,
 12880  	            0x11: 0x8020800,
 12881  	            0x12: 0x20,
 12882  	            0x13: 0x800,
 12883  	            0x14: 0x8000800,
 12884  	            0x15: 0x8000020,
 12885  	            0x16: 0x8020020,
 12886  	            0x17: 0x20000,
 12887  	            0x18: 0x0,
 12888  	            0x19: 0x20020,
 12889  	            0x1a: 0x8020000,
 12890  	            0x1b: 0x8000820,
 12891  	            0x1c: 0x8020820,
 12892  	            0x1d: 0x20800,
 12893  	            0x1e: 0x820,
 12894  	            0x1f: 0x8000000,
 12895  	            0x80000010: 0x20000,
 12896  	            0x80000011: 0x800,
 12897  	            0x80000012: 0x8020020,
 12898  	            0x80000013: 0x20820,
 12899  	            0x80000014: 0x20,
 12900  	            0x80000015: 0x8020000,
 12901  	            0x80000016: 0x8000000,
 12902  	            0x80000017: 0x8000820,
 12903  	            0x80000018: 0x8020820,
 12904  	            0x80000019: 0x8000020,
 12905  	            0x8000001a: 0x8000800,
 12906  	            0x8000001b: 0x0,
 12907  	            0x8000001c: 0x20800,
 12908  	            0x8000001d: 0x820,
 12909  	            0x8000001e: 0x20020,
 12910  	            0x8000001f: 0x8020800
 12911  	        }
 12912  	    ];
 12913  
 12914  	    // Masks that select the SBOX input
 12915  	    var SBOX_MASK = [
 12916  	        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
 12917  	        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
 12918  	    ];
 12919  
 12920  	    /**
 12921  	     * DES block cipher algorithm.
 12922  	     */
 12923  	    var DES = C_algo.DES = BlockCipher.extend({
 12924  	        _doReset: function () {
 12925  	            // Shortcuts
 12926  	            var key = this._key;
 12927  	            var keyWords = key.words;
 12928  
 12929  	            // Select 56 bits according to PC1
 12930  	            var keyBits = [];
 12931  	            for (var i = 0; i < 56; i++) {
 12932  	                var keyBitPos = PC1[i] - 1;
 12933  	                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
 12934  	            }
 12935  
 12936  	            // Assemble 16 subkeys
 12937  	            var subKeys = this._subKeys = [];
 12938  	            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
 12939  	                // Create subkey
 12940  	                var subKey = subKeys[nSubKey] = [];
 12941  
 12942  	                // Shortcut
 12943  	                var bitShift = BIT_SHIFTS[nSubKey];
 12944  
 12945  	                // Select 48 bits according to PC2
 12946  	                for (var i = 0; i < 24; i++) {
 12947  	                    // Select from the left 28 key bits
 12948  	                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
 12949  
 12950  	                    // Select from the right 28 key bits
 12951  	                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
 12952  	                }
 12953  
 12954  	                // Since each subkey is applied to an expanded 32-bit input,
 12955  	                // the subkey can be broken into 8 values scaled to 32-bits,
 12956  	                // which allows the key to be used without expansion
 12957  	                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
 12958  	                for (var i = 1; i < 7; i++) {
 12959  	                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
 12960  	                }
 12961  	                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
 12962  	            }
 12963  
 12964  	            // Compute inverse subkeys
 12965  	            var invSubKeys = this._invSubKeys = [];
 12966  	            for (var i = 0; i < 16; i++) {
 12967  	                invSubKeys[i] = subKeys[15 - i];
 12968  	            }
 12969  	        },
 12970  
 12971  	        encryptBlock: function (M, offset) {
 12972  	            this._doCryptBlock(M, offset, this._subKeys);
 12973  	        },
 12974  
 12975  	        decryptBlock: function (M, offset) {
 12976  	            this._doCryptBlock(M, offset, this._invSubKeys);
 12977  	        },
 12978  
 12979  	        _doCryptBlock: function (M, offset, subKeys) {
 12980  	            // Get input
 12981  	            this._lBlock = M[offset];
 12982  	            this._rBlock = M[offset + 1];
 12983  
 12984  	            // Initial permutation
 12985  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12986  	            exchangeLR.call(this, 16, 0x0000ffff);
 12987  	            exchangeRL.call(this, 2,  0x33333333);
 12988  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12989  	            exchangeLR.call(this, 1,  0x55555555);
 12990  
 12991  	            // Rounds
 12992  	            for (var round = 0; round < 16; round++) {
 12993  	                // Shortcuts
 12994  	                var subKey = subKeys[round];
 12995  	                var lBlock = this._lBlock;
 12996  	                var rBlock = this._rBlock;
 12997  
 12998  	                // Feistel function
 12999  	                var f = 0;
 13000  	                for (var i = 0; i < 8; i++) {
 13001  	                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
 13002  	                }
 13003  	                this._lBlock = rBlock;
 13004  	                this._rBlock = lBlock ^ f;
 13005  	            }
 13006  
 13007  	            // Undo swap from last round
 13008  	            var t = this._lBlock;
 13009  	            this._lBlock = this._rBlock;
 13010  	            this._rBlock = t;
 13011  
 13012  	            // Final permutation
 13013  	            exchangeLR.call(this, 1,  0x55555555);
 13014  	            exchangeRL.call(this, 8,  0x00ff00ff);
 13015  	            exchangeRL.call(this, 2,  0x33333333);
 13016  	            exchangeLR.call(this, 16, 0x0000ffff);
 13017  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 13018  
 13019  	            // Set output
 13020  	            M[offset] = this._lBlock;
 13021  	            M[offset + 1] = this._rBlock;
 13022  	        },
 13023  
 13024  	        keySize: 64/32,
 13025  
 13026  	        ivSize: 64/32,
 13027  
 13028  	        blockSize: 64/32
 13029  	    });
 13030  
 13031  	    // Swap bits across the left and right words
 13032  	    function exchangeLR(offset, mask) {
 13033  	        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
 13034  	        this._rBlock ^= t;
 13035  	        this._lBlock ^= t << offset;
 13036  	    }
 13037  
 13038  	    function exchangeRL(offset, mask) {
 13039  	        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
 13040  	        this._lBlock ^= t;
 13041  	        this._rBlock ^= t << offset;
 13042  	    }
 13043  
 13044  	    /**
 13045  	     * Shortcut functions to the cipher's object interface.
 13046  	     *
 13047  	     * @example
 13048  	     *
 13049  	     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
 13050  	     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
 13051  	     */
 13052  	    C.DES = BlockCipher._createHelper(DES);
 13053  
 13054  	    /**
 13055  	     * Triple-DES block cipher algorithm.
 13056  	     */
 13057  	    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
 13058  	        _doReset: function () {
 13059  	            // Shortcuts
 13060  	            var key = this._key;
 13061  	            var keyWords = key.words;
 13062  
 13063  	            // Create DES instances
 13064  	            this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
 13065  	            this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
 13066  	            this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
 13067  	        },
 13068  
 13069  	        encryptBlock: function (M, offset) {
 13070  	            this._des1.encryptBlock(M, offset);
 13071  	            this._des2.decryptBlock(M, offset);
 13072  	            this._des3.encryptBlock(M, offset);
 13073  	        },
 13074  
 13075  	        decryptBlock: function (M, offset) {
 13076  	            this._des3.decryptBlock(M, offset);
 13077  	            this._des2.encryptBlock(M, offset);
 13078  	            this._des1.decryptBlock(M, offset);
 13079  	        },
 13080  
 13081  	        keySize: 192/32,
 13082  
 13083  	        ivSize: 64/32,
 13084  
 13085  	        blockSize: 64/32
 13086  	    });
 13087  
 13088  	    /**
 13089  	     * Shortcut functions to the cipher's object interface.
 13090  	     *
 13091  	     * @example
 13092  	     *
 13093  	     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
 13094  	     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
 13095  	     */
 13096  	    C.TripleDES = BlockCipher._createHelper(TripleDES);
 13097  	}());
 13098  
 13099  
 13100  	return CryptoJS.TripleDES;
 13101  
 13102  }));
 13103  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
 13104  ;(function (root, factory) {
 13105  	if (typeof exports === "object") {
 13106  		// CommonJS
 13107  		module.exports = exports = factory(require("./core"));
 13108  	}
 13109  	else if (typeof define === "function" && define.amd) {
 13110  		// AMD
 13111  		define(["./core"], factory);
 13112  	}
 13113  	else {
 13114  		// Global (browser)
 13115  		factory(root.CryptoJS);
 13116  	}
 13117  }(this, function (CryptoJS) {
 13118  
 13119  	(function (undefined) {
 13120  	    // Shortcuts
 13121  	    var C = CryptoJS;
 13122  	    var C_lib = C.lib;
 13123  	    var Base = C_lib.Base;
 13124  	    var X32WordArray = C_lib.WordArray;
 13125  
 13126  	    /**
 13127  	     * x64 namespace.
 13128  	     */
 13129  	    var C_x64 = C.x64 = {};
 13130  
 13131  	    /**
 13132  	     * A 64-bit word.
 13133  	     */
 13134  	    var X64Word = C_x64.Word = Base.extend({
 13135  	        /**
 13136  	         * Initializes a newly created 64-bit word.
 13137  	         *
 13138  	         * @param {number} high The high 32 bits.
 13139  	         * @param {number} low The low 32 bits.
 13140  	         *
 13141  	         * @example
 13142  	         *
 13143  	         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
 13144  	         */
 13145  	        init: function (high, low) {
 13146  	            this.high = high;
 13147  	            this.low = low;
 13148  	        }
 13149  
 13150  	        /**
 13151  	         * Bitwise NOTs this word.
 13152  	         *
 13153  	         * @return {X64Word} A new x64-Word object after negating.
 13154  	         *
 13155  	         * @example
 13156  	         *
 13157  	         *     var negated = x64Word.not();
 13158  	         */
 13159  	        // not: function () {
 13160  	            // var high = ~this.high;
 13161  	            // var low = ~this.low;
 13162  
 13163  	            // return X64Word.create(high, low);
 13164  	        // },
 13165  
 13166  	        /**
 13167  	         * Bitwise ANDs this word with the passed word.
 13168  	         *
 13169  	         * @param {X64Word} word The x64-Word to AND with this word.
 13170  	         *
 13171  	         * @return {X64Word} A new x64-Word object after ANDing.
 13172  	         *
 13173  	         * @example
 13174  	         *
 13175  	         *     var anded = x64Word.and(anotherX64Word);
 13176  	         */
 13177  	        // and: function (word) {
 13178  	            // var high = this.high & word.high;
 13179  	            // var low = this.low & word.low;
 13180  
 13181  	            // return X64Word.create(high, low);
 13182  	        // },
 13183  
 13184  	        /**
 13185  	         * Bitwise ORs this word with the passed word.
 13186  	         *
 13187  	         * @param {X64Word} word The x64-Word to OR with this word.
 13188  	         *
 13189  	         * @return {X64Word} A new x64-Word object after ORing.
 13190  	         *
 13191  	         * @example
 13192  	         *
 13193  	         *     var ored = x64Word.or(anotherX64Word);
 13194  	         */
 13195  	        // or: function (word) {
 13196  	            // var high = this.high | word.high;
 13197  	            // var low = this.low | word.low;
 13198  
 13199  	            // return X64Word.create(high, low);
 13200  	        // },
 13201  
 13202  	        /**
 13203  	         * Bitwise XORs this word with the passed word.
 13204  	         *
 13205  	         * @param {X64Word} word The x64-Word to XOR with this word.
 13206  	         *
 13207  	         * @return {X64Word} A new x64-Word object after XORing.
 13208  	         *
 13209  	         * @example
 13210  	         *
 13211  	         *     var xored = x64Word.xor(anotherX64Word);
 13212  	         */
 13213  	        // xor: function (word) {
 13214  	            // var high = this.high ^ word.high;
 13215  	            // var low = this.low ^ word.low;
 13216  
 13217  	            // return X64Word.create(high, low);
 13218  	        // },
 13219  
 13220  	        /**
 13221  	         * Shifts this word n bits to the left.
 13222  	         *
 13223  	         * @param {number} n The number of bits to shift.
 13224  	         *
 13225  	         * @return {X64Word} A new x64-Word object after shifting.
 13226  	         *
 13227  	         * @example
 13228  	         *
 13229  	         *     var shifted = x64Word.shiftL(25);
 13230  	         */
 13231  	        // shiftL: function (n) {
 13232  	            // if (n < 32) {
 13233  	                // var high = (this.high << n) | (this.low >>> (32 - n));
 13234  	                // var low = this.low << n;
 13235  	            // } else {
 13236  	                // var high = this.low << (n - 32);
 13237  	                // var low = 0;
 13238  	            // }
 13239  
 13240  	            // return X64Word.create(high, low);
 13241  	        // },
 13242  
 13243  	        /**
 13244  	         * Shifts this word n bits to the right.
 13245  	         *
 13246  	         * @param {number} n The number of bits to shift.
 13247  	         *
 13248  	         * @return {X64Word} A new x64-Word object after shifting.
 13249  	         *
 13250  	         * @example
 13251  	         *
 13252  	         *     var shifted = x64Word.shiftR(7);
 13253  	         */
 13254  	        // shiftR: function (n) {
 13255  	            // if (n < 32) {
 13256  	                // var low = (this.low >>> n) | (this.high << (32 - n));
 13257  	                // var high = this.high >>> n;
 13258  	            // } else {
 13259  	                // var low = this.high >>> (n - 32);
 13260  	                // var high = 0;
 13261  	            // }
 13262  
 13263  	            // return X64Word.create(high, low);
 13264  	        // },
 13265  
 13266  	        /**
 13267  	         * Rotates this word n bits to the left.
 13268  	         *
 13269  	         * @param {number} n The number of bits to rotate.
 13270  	         *
 13271  	         * @return {X64Word} A new x64-Word object after rotating.
 13272  	         *
 13273  	         * @example
 13274  	         *
 13275  	         *     var rotated = x64Word.rotL(25);
 13276  	         */
 13277  	        // rotL: function (n) {
 13278  	            // return this.shiftL(n).or(this.shiftR(64 - n));
 13279  	        // },
 13280  
 13281  	        /**
 13282  	         * Rotates this word n bits to the right.
 13283  	         *
 13284  	         * @param {number} n The number of bits to rotate.
 13285  	         *
 13286  	         * @return {X64Word} A new x64-Word object after rotating.
 13287  	         *
 13288  	         * @example
 13289  	         *
 13290  	         *     var rotated = x64Word.rotR(7);
 13291  	         */
 13292  	        // rotR: function (n) {
 13293  	            // return this.shiftR(n).or(this.shiftL(64 - n));
 13294  	        // },
 13295  
 13296  	        /**
 13297  	         * Adds this word with the passed word.
 13298  	         *
 13299  	         * @param {X64Word} word The x64-Word to add with this word.
 13300  	         *
 13301  	         * @return {X64Word} A new x64-Word object after adding.
 13302  	         *
 13303  	         * @example
 13304  	         *
 13305  	         *     var added = x64Word.add(anotherX64Word);
 13306  	         */
 13307  	        // add: function (word) {
 13308  	            // var low = (this.low + word.low) | 0;
 13309  	            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
 13310  	            // var high = (this.high + word.high + carry) | 0;
 13311  
 13312  	            // return X64Word.create(high, low);
 13313  	        // }
 13314  	    });
 13315  
 13316  	    /**
 13317  	     * An array of 64-bit words.
 13318  	     *
 13319  	     * @property {Array} words The array of CryptoJS.x64.Word objects.
 13320  	     * @property {number} sigBytes The number of significant bytes in this word array.
 13321  	     */
 13322  	    var X64WordArray = C_x64.WordArray = Base.extend({
 13323  	        /**
 13324  	         * Initializes a newly created word array.
 13325  	         *
 13326  	         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
 13327  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
 13328  	         *
 13329  	         * @example
 13330  	         *
 13331  	         *     var wordArray = CryptoJS.x64.WordArray.create();
 13332  	         *
 13333  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13334  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13335  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13336  	         *     ]);
 13337  	         *
 13338  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13339  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13340  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13341  	         *     ], 10);
 13342  	         */
 13343  	        init: function (words, sigBytes) {
 13344  	            words = this.words = words || [];
 13345  
 13346  	            if (sigBytes != undefined) {
 13347  	                this.sigBytes = sigBytes;
 13348  	            } else {
 13349  	                this.sigBytes = words.length * 8;
 13350  	            }
 13351  	        },
 13352  
 13353  	        /**
 13354  	         * Converts this 64-bit word array to a 32-bit word array.
 13355  	         *
 13356  	         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
 13357  	         *
 13358  	         * @example
 13359  	         *
 13360  	         *     var x32WordArray = x64WordArray.toX32();
 13361  	         */
 13362  	        toX32: function () {
 13363  	            // Shortcuts
 13364  	            var x64Words = this.words;
 13365  	            var x64WordsLength = x64Words.length;
 13366  
 13367  	            // Convert
 13368  	            var x32Words = [];
 13369  	            for (var i = 0; i < x64WordsLength; i++) {
 13370  	                var x64Word = x64Words[i];
 13371  	                x32Words.push(x64Word.high);
 13372  	                x32Words.push(x64Word.low);
 13373  	            }
 13374  
 13375  	            return X32WordArray.create(x32Words, this.sigBytes);
 13376  	        },
 13377  
 13378  	        /**
 13379  	         * Creates a copy of this word array.
 13380  	         *
 13381  	         * @return {X64WordArray} The clone.
 13382  	         *
 13383  	         * @example
 13384  	         *
 13385  	         *     var clone = x64WordArray.clone();
 13386  	         */
 13387  	        clone: function () {
 13388  	            var clone = Base.clone.call(this);
 13389  
 13390  	            // Clone "words" array
 13391  	            var words = clone.words = this.words.slice(0);
 13392  
 13393  	            // Clone each X64Word object
 13394  	            var wordsLength = words.length;
 13395  	            for (var i = 0; i < wordsLength; i++) {
 13396  	                words[i] = words[i].clone();
 13397  	            }
 13398  
 13399  	            return clone;
 13400  	        }
 13401  	    });
 13402  	}());
 13403  
 13404  
 13405  	return CryptoJS;
 13406  
 13407  }));
 13408  },{"./core":53}],85:[function(require,module,exports){
 13409  /*! https://mths.be/utf8js v2.1.2 by @mathias */
 13410  ;(function(root) {
 13411  
 13412  	// Detect free variables `exports`
 13413  	var freeExports = typeof exports == 'object' && exports;
 13414  
 13415  	// Detect free variable `module`
 13416  	var freeModule = typeof module == 'object' && module &&
 13417  		module.exports == freeExports && module;
 13418  
 13419  	// Detect free variable `global`, from Node.js or Browserified code,
 13420  	// and use it as `root`
 13421  	var freeGlobal = typeof global == 'object' && global;
 13422  	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
 13423  		root = freeGlobal;
 13424  	}
 13425  
 13426  	/*--------------------------------------------------------------------------*/
 13427  
 13428  	var stringFromCharCode = String.fromCharCode;
 13429  
 13430  	// Taken from https://mths.be/punycode
 13431  	function ucs2decode(string) {
 13432  		var output = [];
 13433  		var counter = 0;
 13434  		var length = string.length;
 13435  		var value;
 13436  		var extra;
 13437  		while (counter < length) {
 13438  			value = string.charCodeAt(counter++);
 13439  			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
 13440  				// high surrogate, and there is a next character
 13441  				extra = string.charCodeAt(counter++);
 13442  				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
 13443  					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
 13444  				} else {
 13445  					// unmatched surrogate; only append this code unit, in case the next
 13446  					// code unit is the high surrogate of a surrogate pair
 13447  					output.push(value);
 13448  					counter--;
 13449  				}
 13450  			} else {
 13451  				output.push(value);
 13452  			}
 13453  		}
 13454  		return output;
 13455  	}
 13456  
 13457  	// Taken from https://mths.be/punycode
 13458  	function ucs2encode(array) {
 13459  		var length = array.length;
 13460  		var index = -1;
 13461  		var value;
 13462  		var output = '';
 13463  		while (++index < length) {
 13464  			value = array[index];
 13465  			if (value > 0xFFFF) {
 13466  				value -= 0x10000;
 13467  				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
 13468  				value = 0xDC00 | value & 0x3FF;
 13469  			}
 13470  			output += stringFromCharCode(value);
 13471  		}
 13472  		return output;
 13473  	}
 13474  
 13475  	function checkScalarValue(codePoint) {
 13476  		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
 13477  			throw Error(
 13478  				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
 13479  				' is not a scalar value'
 13480  			);
 13481  		}
 13482  	}
 13483  	/*--------------------------------------------------------------------------*/
 13484  
 13485  	function createByte(codePoint, shift) {
 13486  		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
 13487  	}
 13488  
 13489  	function encodeCodePoint(codePoint) {
 13490  		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
 13491  			return stringFromCharCode(codePoint);
 13492  		}
 13493  		var symbol = '';
 13494  		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
 13495  			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
 13496  		}
 13497  		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
 13498  			checkScalarValue(codePoint);
 13499  			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
 13500  			symbol += createByte(codePoint, 6);
 13501  		}
 13502  		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
 13503  			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
 13504  			symbol += createByte(codePoint, 12);
 13505  			symbol += createByte(codePoint, 6);
 13506  		}
 13507  		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
 13508  		return symbol;
 13509  	}
 13510  
 13511  	function utf8encode(string) {
 13512  		var codePoints = ucs2decode(string);
 13513  		var length = codePoints.length;
 13514  		var index = -1;
 13515  		var codePoint;
 13516  		var byteString = '';
 13517  		while (++index < length) {
 13518  			codePoint = codePoints[index];
 13519  			byteString += encodeCodePoint(codePoint);
 13520  		}
 13521  		return byteString;
 13522  	}
 13523  
 13524  	/*--------------------------------------------------------------------------*/
 13525  
 13526  	function readContinuationByte() {
 13527  		if (byteIndex >= byteCount) {
 13528  			throw Error('Invalid byte index');
 13529  		}
 13530  
 13531  		var continuationByte = byteArray[byteIndex] & 0xFF;
 13532  		byteIndex++;
 13533  
 13534  		if ((continuationByte & 0xC0) == 0x80) {
 13535  			return continuationByte & 0x3F;
 13536  		}
 13537  
 13538  		// If we end up here, it’s not a continuation byte
 13539  		throw Error('Invalid continuation byte');
 13540  	}
 13541  
 13542  	function decodeSymbol() {
 13543  		var byte1;
 13544  		var byte2;
 13545  		var byte3;
 13546  		var byte4;
 13547  		var codePoint;
 13548  
 13549  		if (byteIndex > byteCount) {
 13550  			throw Error('Invalid byte index');
 13551  		}
 13552  
 13553  		if (byteIndex == byteCount) {
 13554  			return false;
 13555  		}
 13556  
 13557  		// Read first byte
 13558  		byte1 = byteArray[byteIndex] & 0xFF;
 13559  		byteIndex++;
 13560  
 13561  		// 1-byte sequence (no continuation bytes)
 13562  		if ((byte1 & 0x80) == 0) {
 13563  			return byte1;
 13564  		}
 13565  
 13566  		// 2-byte sequence
 13567  		if ((byte1 & 0xE0) == 0xC0) {
 13568  			byte2 = readContinuationByte();
 13569  			codePoint = ((byte1 & 0x1F) << 6) | byte2;
 13570  			if (codePoint >= 0x80) {
 13571  				return codePoint;
 13572  			} else {
 13573  				throw Error('Invalid continuation byte');
 13574  			}
 13575  		}
 13576  
 13577  		// 3-byte sequence (may include unpaired surrogates)
 13578  		if ((byte1 & 0xF0) == 0xE0) {
 13579  			byte2 = readContinuationByte();
 13580  			byte3 = readContinuationByte();
 13581  			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
 13582  			if (codePoint >= 0x0800) {
 13583  				checkScalarValue(codePoint);
 13584  				return codePoint;
 13585  			} else {
 13586  				throw Error('Invalid continuation byte');
 13587  			}
 13588  		}
 13589  
 13590  		// 4-byte sequence
 13591  		if ((byte1 & 0xF8) == 0xF0) {
 13592  			byte2 = readContinuationByte();
 13593  			byte3 = readContinuationByte();
 13594  			byte4 = readContinuationByte();
 13595  			codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
 13596  				(byte3 << 0x06) | byte4;
 13597  			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
 13598  				return codePoint;
 13599  			}
 13600  		}
 13601  
 13602  		throw Error('Invalid UTF-8 detected');
 13603  	}
 13604  
 13605  	var byteArray;
 13606  	var byteCount;
 13607  	var byteIndex;
 13608  	function utf8decode(byteString) {
 13609  		byteArray = ucs2decode(byteString);
 13610  		byteCount = byteArray.length;
 13611  		byteIndex = 0;
 13612  		var codePoints = [];
 13613  		var tmp;
 13614  		while ((tmp = decodeSymbol()) !== false) {
 13615  			codePoints.push(tmp);
 13616  		}
 13617  		return ucs2encode(codePoints);
 13618  	}
 13619  
 13620  	/*--------------------------------------------------------------------------*/
 13621  
 13622  	var utf8 = {
 13623  		'version': '2.1.2',
 13624  		'encode': utf8encode,
 13625  		'decode': utf8decode
 13626  	};
 13627  
 13628  	// Some AMD build optimizers, like r.js, check for specific condition patterns
 13629  	// like the following:
 13630  	if (
 13631  		typeof define == 'function' &&
 13632  		typeof define.amd == 'object' &&
 13633  		define.amd
 13634  	) {
 13635  		define(function() {
 13636  			return utf8;
 13637  		});
 13638  	}	else if (freeExports && !freeExports.nodeType) {
 13639  		if (freeModule) { // in Node.js or RingoJS v0.8.0+
 13640  			freeModule.exports = utf8;
 13641  		} else { // in Narwhal or RingoJS v0.7.0-
 13642  			var object = {};
 13643  			var hasOwnProperty = object.hasOwnProperty;
 13644  			for (var key in utf8) {
 13645  				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
 13646  			}
 13647  		}
 13648  	} else { // in Rhino or a web browser
 13649  		root.utf8 = utf8;
 13650  	}
 13651  
 13652  }(this));
 13653  
 13654  },{}],86:[function(require,module,exports){
 13655  module.exports = XMLHttpRequest;
 13656  
 13657  },{}],"bignumber.js":[function(require,module,exports){
 13658  'use strict';
 13659  
 13660  module.exports = BigNumber; // jshint ignore:line
 13661  
 13662  
 13663  },{}],"web3":[function(require,module,exports){
 13664  var Web3 = require('./lib/web3');
 13665  
 13666  // dont override global variable
 13667  if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
 13668      window.Web3 = Web3;
 13669  }
 13670  
 13671  module.exports = Web3;
 13672  
 13673  },{"./lib/web3":22}]},{},["web3"])
 13674  //# sourceMappingURL=web3-light.js.map