aboutsummaryrefslogtreecommitdiffstats
path: root/jsre
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-11-24 16:37:29 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-11-26 20:38:53 +0800
commitb1e014344494d2713f6091299a5b86dc53e1fb4e (patch)
treef40651917362c3a70160011f87808f62c37ecee3 /jsre
parent6bb29aebeefc64c765f0a2b5ab66f85d928f56cd (diff)
downloadgo-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.tar
go-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.tar.gz
go-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.tar.bz2
go-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.tar.lz
go-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.tar.xz
go-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.tar.zst
go-tangerine-b1e014344494d2713f6091299a5b86dc53e1fb4e.zip
cmd, crypto: fixed nil public keys and updated web3
Diffstat (limited to 'jsre')
-rw-r--r--jsre/ethereum_js.go7168
1 files changed, 6224 insertions, 944 deletions
diff --git a/jsre/ethereum_js.go b/jsre/ethereum_js.go
index 2d7dbfec0..7063a90ec 100644
--- a/jsre/ethereum_js.go
+++ b/jsre/ethereum_js.go
@@ -272,6 +272,7 @@ module.exports=[
"type": "event"
}
]
+
},{}],2:[function(require,module,exports){
module.exports=[
{
@@ -381,6 +382,7 @@ module.exports=[
"type": "event"
}
]
+
},{}],3:[function(require,module,exports){
module.exports=[
{
@@ -528,6 +530,7 @@ module.exports=[
"type": "event"
}
]
+
},{}],4:[function(require,module,exports){
var f = require('./formatters');
var SolidityType = require('./type');
@@ -635,22 +638,22 @@ module.exports = SolidityTypeBytes;
},{"./formatters":9,"./type":14}],7:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file coder.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
@@ -680,7 +683,7 @@ var SolidityCoder = function (types) {
*
* @method _requireType
* @param {String} type
- * @returns {SolidityType}
+ * @returns {SolidityType}
* @throws {Error} throws if no matching type is found
*/
SolidityCoder.prototype._requireType = function (type) {
@@ -723,10 +726,12 @@ SolidityCoder.prototype.encodeParams = function (types, params) {
});
var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
- return acc + solidityType.staticPartLength(types[index]);
+ var staticPartLength = solidityType.staticPartLength(types[index]);
+ var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
+ return acc + roundedStaticPartLength;
}, 0);
- var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
+ var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
return result;
};
@@ -751,7 +756,7 @@ SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes,
// TODO: figure out nested arrays
});
-
+
types.forEach(function (type, i) {
if (isDynamic(i)) {
var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
@@ -771,7 +776,7 @@ SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded
var nestedName = solidityType.nestedName(type);
var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
var result = encoded[0];
-
+
(function () {
var previousLength = 2; // in int
if (solidityType.isDynamicArray(nestedName)) {
@@ -781,7 +786,7 @@ SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded
}
}
})();
-
+
// first element is length, skip it
(function () {
for (var i = 0; i < encoded.length - 1; i++) {
@@ -792,7 +797,7 @@ SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded
return result;
})();
-
+
} else if (solidityType.isStaticArray(type)) {
return (function () {
var nestedName = solidityType.nestedName(type);
@@ -805,7 +810,7 @@ SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded
var previousLength = 0; // in int
for (var i = 0; i < encoded.length; i++) {
// calculate length of previous item
- previousLength += +(encoded[i - 1] || [])[0] || 0;
+ previousLength += +(encoded[i - 1] || [])[0] || 0;
result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
}
})();
@@ -848,7 +853,7 @@ SolidityCoder.prototype.decodeParam = function (type, bytes) {
SolidityCoder.prototype.decodeParams = function (types, bytes) {
var solidityTypes = this.getSolidityTypes(types);
var offsets = this.getOffsets(types, solidityTypes);
-
+
return solidityTypes.map(function (solidityType, index) {
return solidityType.decode(bytes, offsets[index], types[index], index);
});
@@ -857,18 +862,17 @@ SolidityCoder.prototype.decodeParams = function (types, bytes) {
SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
var lengths = solidityTypes.map(function (solidityType, index) {
return solidityType.staticPartLength(types[index]);
- // get length
});
-
- for (var i = 0; i < lengths.length; i++) {
+
+ for (var i = 1; i < lengths.length; i++) {
// sum with length of previous element
- var previous = (lengths[i - 1] || 0);
- lengths[i] += previous;
+ lengths[i] += lengths[i - 1];
}
return lengths.map(function (length, index) {
// remove the current length, so the length is sum of previous elements
- return length - solidityTypes[index].staticPartLength(types[index]);
+ var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
+ return length - staticPartLength;
});
};
@@ -923,22 +927,22 @@ module.exports = SolidityTypeDynamicBytes;
},{"./formatters":9,"./type":14}],9:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file formatters.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
@@ -1082,7 +1086,7 @@ var formatOutputUInt = function (param) {
* @returns {BigNumber} input bytes formatted to real
*/
var formatOutputReal = function (param) {
- return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
+ return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
};
/**
@@ -1093,7 +1097,7 @@ var formatOutputReal = function (param) {
* @returns {BigNumber} input bytes formatted to ureal
*/
var formatOutputUReal = function (param) {
- return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
+ return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
};
/**
@@ -1213,22 +1217,22 @@ module.exports = SolidityTypeInt;
},{"./formatters":9,"./type":14}],11:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file param.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
@@ -1247,7 +1251,7 @@ var SolidityParam = function (value, offset) {
/**
* This method should be used to get length of params's dynamic part
- *
+ *
* @method dynamicPartLength
* @returns {Number} length of dynamic part (in bytes)
*/
@@ -1275,7 +1279,7 @@ SolidityParam.prototype.withOffset = function (offset) {
* @param {SolidityParam} result of combination
*/
SolidityParam.prototype.combine = function (param) {
- return new SolidityParam(this.value + param.value);
+ return new SolidityParam(this.value + param.value);
};
/**
@@ -1307,8 +1311,8 @@ SolidityParam.prototype.offsetAsBytes = function () {
*/
SolidityParam.prototype.staticPart = function () {
if (!this.isDynamic()) {
- return this.value;
- }
+ return this.value;
+ }
return this.offsetAsBytes();
};
@@ -1340,7 +1344,7 @@ SolidityParam.prototype.encode = function () {
* @returns {String}
*/
SolidityParam.encodeList = function (params) {
-
+
// updating offsets
var totalOffset = params.length * 32;
var offsetParams = params.map(function (param) {
@@ -1466,13 +1470,13 @@ SolidityType.prototype.staticPartLength = function (name) {
/**
* Should be used to determine if type is dynamic array
- * eg:
+ * eg:
* "type[]" => true
* "type[4]" => false
*
* @method isDynamicArray
* @param {String} name
- * @return {Bool} true if the type is dynamic array
+ * @return {Bool} true if the type is dynamic array
*/
SolidityType.prototype.isDynamicArray = function (name) {
var nestedTypes = this.nestedTypes(name);
@@ -1481,13 +1485,13 @@ SolidityType.prototype.isDynamicArray = function (name) {
/**
* Should be used to determine if type is static array
- * eg:
+ * eg:
* "type[]" => false
* "type[4]" => true
*
* @method isStaticArray
* @param {String} name
- * @return {Bool} true if the type is static array
+ * @return {Bool} true if the type is static array
*/
SolidityType.prototype.isStaticArray = function (name) {
var nestedTypes = this.nestedTypes(name);
@@ -1496,7 +1500,7 @@ SolidityType.prototype.isStaticArray = function (name) {
/**
* Should return length of static array
- * eg.
+ * eg.
* "int[32]" => 32
* "int256[14]" => 14
* "int[2][3]" => 3
@@ -1571,7 +1575,7 @@ SolidityType.prototype.nestedTypes = function (name) {
* Should be used to encode the value
*
* @method encode
- * @param {Object} value
+ * @param {Object} value
* @param {String} name
* @return {String} encoded value
*/
@@ -1585,7 +1589,7 @@ SolidityType.prototype.encode = function (value, name) {
var result = [];
result.push(f.formatInputInt(length).encode());
-
+
value.forEach(function (v) {
result.push(self.encode(v, nestedName));
});
@@ -1633,9 +1637,10 @@ SolidityType.prototype.decode = function (bytes, offset, name) {
var nestedName = self.nestedName(name);
var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
+ var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
var result = [];
- for (var i = 0; i < length * nestedStaticPartLength; i += nestedStaticPartLength) {
+ for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
result.push(self.decode(bytes, arrayStart + i, nestedName));
}
@@ -1650,21 +1655,22 @@ SolidityType.prototype.decode = function (bytes, offset, name) {
var nestedName = self.nestedName(name);
var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
+ var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
var result = [];
- for (var i = 0; i < length * nestedStaticPartLength; i += nestedStaticPartLength) {
+ for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
result.push(self.decode(bytes, arrayStart + i, nestedName));
}
return result;
})();
} else if (this.isDynamicType(name)) {
-
+
return (function () {
var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64)); // in bytes
var roundedLength = Math.floor((length + 31) / 32); // in int
-
+
return self._outputFormatter(new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0));
})();
}
@@ -1764,20 +1770,20 @@ if (typeof XMLHttpRequest === 'undefined') {
},{}],18:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file config.js
* @authors:
@@ -1787,13 +1793,13 @@ if (typeof XMLHttpRequest === 'undefined') {
/**
* Utils
- *
+ *
* @module utils
*/
/**
* Utility functions
- *
+ *
* @class [utils] config
* @constructor
*/
@@ -1845,62 +1851,60 @@ module.exports = {
},{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file sha3.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
-
-var utils = require('./utils');
+var CryptoJS = require('crypto-js');
var sha3 = require('crypto-js/sha3');
-module.exports = function (str, isNew) {
- if (str.substr(0, 2) === '0x' && !isNew) {
- console.warn('requirement of using web3.fromAscii before sha3 is deprecated');
- console.warn('new usage: \'web3.sha3("hello")\'');
- console.warn('see https://github.com/ethereum/web3.js/pull/205');
- console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\'');
- str = utils.toUtf8(str);
+module.exports = function (value, options) {
+ if (options && options.encoding === 'hex') {
+ if (value.length > 2 && value.substr(0, 2) === '0x') {
+ value = value.substr(2);
+ }
+ value = CryptoJS.enc.Hex.parse(value);
}
- return sha3(str, {
+ return sha3(value, {
outputLength: 256
}).toString();
};
-},{"./utils":20,"crypto-js/sha3":48}],20:[function(require,module,exports){
+},{"crypto-js":57,"crypto-js/sha3":78}],20:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file utils.js
@@ -1994,6 +1998,8 @@ var toUtf8 = function(hex) {
}
for (; i < l; i+=2) {
var code = parseInt(hex.substr(i, 2), 16);
+ if (code === 0)
+ break;
str += String.fromCharCode(code);
}
@@ -2023,7 +2029,7 @@ var toAscii = function(hex) {
};
/**
- * Shold be called to get hex representation (prefixed by 0x) of utf8 string
+ * Should be called to get hex representation (prefixed by 0x) of utf8 a string
*
* @method fromUtf8
* @param {String} string
@@ -2034,7 +2040,10 @@ var fromUtf8 = function(str) {
str = utf8.encode(str);
var hex = "";
for(var i = 0; i < str.length; i++) {
- var n = str.charCodeAt(i).toString(16);
+ var code = str.charCodeAt(i);
+ if (code === 0)
+ break;
+ var n = code.toString(16);
hex += n.length < 2 ? '0' + n : n;
}
@@ -2042,7 +2051,7 @@ var fromUtf8 = function(str) {
};
/**
- * Shold be called to get hex representation (prefixed by 0x) of ascii string
+ * Should be called to get hex representation (prefixed by 0x) of ascii string
*
* @method fromAscii
* @param {String} string
@@ -2301,7 +2310,6 @@ var toAddress = function (address) {
return '0x' + padLeft(toHex(address).substr(2), 40);
};
-
/**
* Returns true if object is BigNumber, otherwise false
*
@@ -2414,29 +2422,30 @@ module.exports = {
isJson: isJson
};
-},{"bignumber.js":"bignumber.js","utf8":50}],21:[function(require,module,exports){
+},{"bignumber.js":"bignumber.js","utf8":83}],21:[function(require,module,exports){
module.exports={
- "version": "0.13.0"
+ "version": "0.15.1"
}
},{}],22:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file web3.js
+/**
+ * @file web3.js
* @authors:
* Jeffrey Wilcke <jeff@ethdev.com>
* Marek Kotewicz <marek@ethdev.com>
@@ -2446,181 +2455,136 @@ module.exports={
* @date 2014
*/
+var RequestManager = require('./web3/requestmanager');
+var Iban = require('./web3/iban');
+var Eth = require('./web3/methods/eth');
+var DB = require('./web3/methods/db');
+var Shh = require('./web3/methods/shh');
+var Net = require('./web3/methods/net');
+var Settings = require('./web3/settings');
var version = require('./version.json');
-var net = require('./web3/methods/net');
-var eth = require('./web3/methods/eth');
-var db = require('./web3/methods/db');
-var shh = require('./web3/methods/shh');
-var watches = require('./web3/methods/watches');
-var Filter = require('./web3/filter');
-var IsSyncing = require('./web3/syncing');
var utils = require('./utils/utils');
-var formatters = require('./web3/formatters');
-var RequestManager = require('./web3/requestmanager');
-var c = require('./utils/config');
-var Property = require('./web3/property');
-var Batch = require('./web3/batch');
var sha3 = require('./utils/sha3');
+var extend = require('./web3/extend');
+var Batch = require('./web3/batch');
+var Property = require('./web3/property');
+var HttpProvider = require('./web3/httpprovider');
+var IpcProvider = require('./web3/ipcprovider');
-var web3Properties = [
- new Property({
- name: 'version.client',
- getter: 'web3_clientVersion'
- }),
- new Property({
- name: 'version.network',
- getter: 'net_version',
- inputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'version.ethereum',
- getter: 'eth_protocolVersion',
- inputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'version.whisper',
- getter: 'shh_version',
- inputFormatter: utils.toDecimal
- })
-];
-/// creates methods in a given object based on method description on input
-/// setups api calls for these methods
-var setupMethods = function (obj, methods) {
- methods.forEach(function (method) {
- method.attachToObject(obj);
- });
-};
-/// creates properties in a given object based on properties description on input
-/// setups api calls for these properties
-var setupProperties = function (obj, properties) {
- properties.forEach(function (property) {
- property.attachToObject(obj);
+function Web3 (provider) {
+ this._requestManager = new RequestManager(provider);
+ this.currentProvider = provider;
+ this.eth = new Eth(this);
+ this.db = new DB(this);
+ this.shh = new Shh(this);
+ this.net = new Net(this);
+ this.settings = new Settings();
+ this.version = {
+ api: version.version
+ };
+ this.providers = {
+ HttpProvider: HttpProvider,
+ IpcProvider: IpcProvider
+ };
+ this._extend = extend(this);
+ this._extend({
+ properties: properties()
});
-};
-
-/// setups web3 object, and it's in-browser executed methods
-var web3 = {};
-web3.providers = {};
-web3.currentProvider = null;
-web3.version = {};
-web3.version.api = version.version;
-web3.eth = {};
+}
-web3.eth.isSyncing = function (callback) {
- return new IsSyncing(callback);
+// expose providers on the class
+Web3.providers = {
+ HttpProvider: HttpProvider,
+ IpcProvider: IpcProvider
};
-/*jshint maxparams:4 */
-web3.eth.filter = function (fil, callback) {
- return new Filter(fil, watches.eth(), formatters.outputLogFormatter, callback);
+Web3.prototype.setProvider = function (provider) {
+ this._requestManager.setProvider(provider);
+ this.currentProvider = provider;
};
-/*jshint maxparams:3 */
-web3.shh = {};
-web3.shh.filter = function (fil, callback) {
- return new Filter(fil, watches.shh(), formatters.outputPostFormatter, callback);
+Web3.prototype.reset = function (keepIsSyncing) {
+ this._requestManager.reset(keepIsSyncing);
+ this.settings = new Settings();
};
-web3.net = {};
-web3.db = {};
-web3.setProvider = function (provider) {
- this.currentProvider = provider;
- RequestManager.getInstance().setProvider(provider);
-};
-web3.isConnected = function(){
- return (this.currentProvider && this.currentProvider.isConnected());
-};
-web3.reset = function (keepIsSyncing) {
- RequestManager.getInstance().reset(keepIsSyncing);
- c.defaultBlock = 'latest';
- c.defaultAccount = undefined;
-};
-web3.toHex = utils.toHex;
-web3.toAscii = utils.toAscii;
-web3.toUtf8 = utils.toUtf8;
-web3.fromAscii = utils.fromAscii;
-web3.fromUtf8 = utils.fromUtf8;
-web3.toDecimal = utils.toDecimal;
-web3.fromDecimal = utils.fromDecimal;
-web3.toBigNumber = utils.toBigNumber;
-web3.toWei = utils.toWei;
-web3.fromWei = utils.fromWei;
-web3.isAddress = utils.isAddress;
-web3.isIBAN = utils.isIBAN;
-web3.sha3 = sha3;
-web3.createBatch = function () {
- return new Batch();
-};
-
-// ADD defaultblock
-Object.defineProperty(web3.eth, 'defaultBlock', {
- get: function () {
- return c.defaultBlock;
- },
- set: function (val) {
- c.defaultBlock = val;
- return val;
- }
-});
-
-Object.defineProperty(web3.eth, 'defaultAccount', {
- get: function () {
- return c.defaultAccount;
- },
- set: function (val) {
- c.defaultAccount = val;
- return val;
- }
-});
+Web3.prototype.toHex = utils.toHex;
+Web3.prototype.toAscii = utils.toAscii;
+Web3.prototype.toUtf8 = utils.toUtf8;
+Web3.prototype.fromAscii = utils.fromAscii;
+Web3.prototype.fromUtf8 = utils.fromUtf8;
+Web3.prototype.toDecimal = utils.toDecimal;
+Web3.prototype.fromDecimal = utils.fromDecimal;
+Web3.prototype.toBigNumber = utils.toBigNumber;
+Web3.prototype.toWei = utils.toWei;
+Web3.prototype.fromWei = utils.fromWei;
+Web3.prototype.isAddress = utils.isAddress;
+Web3.prototype.isIBAN = utils.isIBAN;
+Web3.prototype.sha3 = sha3;
-// EXTEND
-web3._extend = function(extension){
- /*jshint maxcomplexity: 6 */
-
- if(extension.property && !web3[extension.property])
- web3[extension.property] = {};
+/**
+ * Transforms direct icap to address
+ */
+Web3.prototype.fromICAP = function (icap) {
+ var iban = new Iban(icap);
+ return iban.address();
+};
- setupMethods(web3[extension.property] || web3, extension.methods || []);
- setupProperties(web3[extension.property] || web3, extension.properties || []);
+var properties = function () {
+ return [
+ new Property({
+ name: 'version.node',
+ getter: 'web3_clientVersion'
+ }),
+ new Property({
+ name: 'version.network',
+ getter: 'net_version',
+ inputFormatter: utils.toDecimal
+ }),
+ new Property({
+ name: 'version.ethereum',
+ getter: 'eth_protocolVersion',
+ inputFormatter: utils.toDecimal
+ }),
+ new Property({
+ name: 'version.whisper',
+ getter: 'shh_version',
+ inputFormatter: utils.toDecimal
+ })
+ ];
};
-web3._extend.formatters = formatters;
-web3._extend.utils = utils;
-web3._extend.Method = require('./web3/method');
-web3._extend.Property = require('./web3/property');
+Web3.prototype.isConnected = function(){
+ return (this.currentProvider && this.currentProvider.isConnected());
+};
-/// setups all api methods
-setupProperties(web3, web3Properties);
-setupMethods(web3.net, net.methods);
-setupProperties(web3.net, net.properties);
-setupMethods(web3.eth, eth.methods);
-setupProperties(web3.eth, eth.properties);
-setupMethods(web3.db, db.methods);
-setupMethods(web3.shh, shh.methods);
+Web3.prototype.createBatch = function () {
+ return new Batch(this);
+};
-module.exports = web3;
+module.exports = Web3;
-},{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43,"./web3/syncing":44}],23:[function(require,module,exports){
+},{"./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/shh":40,"./web3/property":43,"./web3/requestmanager":44,"./web3/settings":45}],23:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file allevents.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2014
@@ -2633,7 +2597,8 @@ var utils = require('../utils/utils');
var Filter = require('./filter');
var watches = require('./methods/watches');
-var AllSolidityEvents = function (json, address) {
+var AllSolidityEvents = function (requestManager, json, address) {
+ this._requestManager = requestManager;
this._json = json;
this._address = address;
};
@@ -2667,7 +2632,7 @@ AllSolidityEvents.prototype.decode = function (data) {
return data;
}
- var event = new SolidityEvent(match, this._address);
+ var event = new SolidityEvent(this._requestManager, match, this._address);
return event.decode(data);
};
@@ -2681,7 +2646,7 @@ AllSolidityEvents.prototype.execute = function (options, callback) {
var o = this.encode(options);
var formatter = this.decode.bind(this);
- return new Filter(o, watches.eth(), formatter, callback);
+ return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
};
AllSolidityEvents.prototype.attachToContract = function (contract) {
@@ -2692,34 +2657,34 @@ AllSolidityEvents.prototype.attachToContract = function (contract) {
module.exports = AllSolidityEvents;
-},{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":28,"./formatters":29,"./methods/watches":40}],24:[function(require,module,exports){
+},{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":41}],24:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file batch.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
-var RequestManager = require('./requestmanager');
var Jsonrpc = require('./jsonrpc');
var errors = require('./errors');
-var Batch = function () {
+var Batch = function (web3) {
+ this.requestManager = web3._requestManager;
this.requests = [];
};
@@ -2740,7 +2705,7 @@ Batch.prototype.add = function (request) {
*/
Batch.prototype.execute = function () {
var requests = this.requests;
- RequestManager.getInstance().sendBatch(requests, function (err, results) {
+ this.requestManager.sendBatch(requests, function (err, results) {
results = results || [];
requests.map(function (request, index) {
return results[index] || {};
@@ -2754,36 +2719,35 @@ Batch.prototype.execute = function () {
requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
}
});
- });
+ });
};
module.exports = Batch;
-},{"./errors":26,"./jsonrpc":34,"./requestmanager":43}],25:[function(require,module,exports){
+},{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file contract.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
-var web3 = require('../web3');
var utils = require('../utils/utils');
var coder = require('../solidity/coder');
var SolidityEvent = require('./event');
@@ -2816,11 +2780,11 @@ var encodeConstructorParams = function (abi, params) {
* @param {Contract} contract
* @param {Array} abi
*/
-var addFunctionsToContract = function (contract, abi) {
- abi.filter(function (json) {
+var addFunctionsToContract = function (contract) {
+ contract.abi.filter(function (json) {
return json.type === 'function';
}).map(function (json) {
- return new SolidityFunction(json, contract.address);
+ return new SolidityFunction(contract._eth, json, contract.address);
}).forEach(function (f) {
f.attachToContract(contract);
});
@@ -2833,31 +2797,21 @@ var addFunctionsToContract = function (contract, abi) {
* @param {Contract} contract
* @param {Array} abi
*/
-var addEventsToContract = function (contract, abi) {
- var events = abi.filter(function (json) {
+var addEventsToContract = function (contract) {
+ var events = contract.abi.filter(function (json) {
return json.type === 'event';
});
- var All = new AllEvents(events, contract.address);
+ var All = new AllEvents(contract._eth._requestManager, events, contract.address);
All.attachToContract(contract);
-
+
events.map(function (json) {
- return new SolidityEvent(json, contract.address);
+ return new SolidityEvent(contract._eth._requestManager, json, contract.address);
}).forEach(function (e) {
e.attachToContract(contract);
});
};
-/**
- * Should be called to create new ContractFactory
- *
- * @method contract
- * @param {Array} abi
- * @returns {ContractFactory} new contract factory
- */
-var contract = function (abi) {
- return new ContractFactory(abi);
-};
/**
* Should be called to check if the contract gets properly deployed on the blockchain.
@@ -2867,24 +2821,22 @@ var contract = function (abi) {
* @param {Function} callback
* @returns {Undefined}
*/
-var checkForContractAddress = function(contract, abi, callback){
+var checkForContractAddress = function(contract, callback){
var count = 0,
callbackFired = false;
// wait for receipt
- var filter = web3.eth.filter('latest', function(e){
- if(!e && !callbackFired) {
+ var filter = contract._eth.filter('latest', function(e){
+ if (!e && !callbackFired) {
count++;
- // console.log('Checking for contract address', count);
-
// stop watching after 50 blocks (timeout)
- if(count > 50) {
-
+ if (count > 50) {
+
filter.stopWatching();
callbackFired = true;
- if(callback)
+ if (callback)
callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
else
throw new Error('Contract transaction couldn\'t be found after 50 blocks');
@@ -2892,15 +2844,15 @@ var checkForContractAddress = function(contract, abi, callback){
} else {
- web3.eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
+ contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
if(receipt && !callbackFired) {
- web3.eth.getCode(receipt.contractAddress, function(e, code){
- /*jshint maxcomplexity: 5 */
+ contract._eth.getCode(receipt.contractAddress, function(e, code){
+ /*jshint maxcomplexity: 6 */
- if(callbackFired)
+ if(callbackFired || !code)
return;
-
+
filter.stopWatching();
callbackFired = true;
@@ -2910,9 +2862,9 @@ var checkForContractAddress = function(contract, abi, callback){
contract.address = receipt.contractAddress;
- // attach events and methods
- addFunctionsToContract(contract, abi);
- addEventsToContract(contract, abi);
+ // attach events and methods again after we have
+ addFunctionsToContract(contract);
+ addEventsToContract(contract);
// call callback for the second time
if(callback)
@@ -2938,13 +2890,27 @@ var checkForContractAddress = function(contract, abi, callback){
* @method ContractFactory
* @param {Array} abi
*/
-var ContractFactory = function (abi) {
+var ContractFactory = function (eth, abi) {
+ this.eth = eth;
this.abi = abi;
+
+ this.new.getData = this.getData.bind(this);
};
/**
- * Should be called to create new contract on a blockchain
+ * Should be called to create new ContractFactory
*
+ * @method contract
+ * @param {Array} abi
+ * @returns {ContractFactory} new contract factory
+ */
+//var contract = function (abi) {
+ //return new ContractFactory(abi);
+//};
+
+/**
+ * Should be called to create new contract on a blockchain
+ *
* @method new
* @param {Any} contract constructor param1 (optional)
* @param {Any} contract constructor param2 (optional)
@@ -2953,8 +2919,7 @@ var ContractFactory = function (abi) {
* @returns {Contract} returns contract instance
*/
ContractFactory.prototype.new = function () {
- var _this = this;
- var contract = new Contract(this.abi);
+ var contract = new Contract(this.eth, this.abi);
// parse arguments
var options = {}; // required!
@@ -2970,16 +2935,13 @@ ContractFactory.prototype.new = function () {
options = args.pop();
}
- // throw an error if there are no options
-
var bytes = encodeConstructorParams(this.abi, args);
options.data += bytes;
-
- if(callback) {
+ if (callback) {
// wait for the contract address adn check if the code was deployed
- web3.eth.sendTransaction(options, function (err, hash) {
+ this.eth.sendTransaction(options, function (err, hash) {
if (err) {
callback(err);
} else {
@@ -2989,14 +2951,14 @@ ContractFactory.prototype.new = function () {
// call callback for the first time
callback(null, contract);
- checkForContractAddress(contract, _this.abi, callback);
+ checkForContractAddress(contract, callback);
}
});
} else {
- var hash = web3.eth.sendTransaction(options);
+ var hash = this.eth.sendTransaction(options);
// add the transaction hash
contract.transactionHash = hash;
- checkForContractAddress(contract, _this.abi);
+ checkForContractAddress(contract);
}
return contract;
@@ -3012,51 +2974,74 @@ ContractFactory.prototype.new = function () {
* otherwise calls callback function (err, contract)
*/
ContractFactory.prototype.at = function (address, callback) {
- var contract = new Contract(this.abi, address);
- // TODO: address is required
-
- // attach functions
- addFunctionsToContract(contract, this.abi);
- addEventsToContract(contract, this.abi);
+ var contract = new Contract(this.eth, this.abi, address);
+ // this functions are not part of prototype,
+ // because we dont want to spoil the interface
+ addFunctionsToContract(contract);
+ addEventsToContract(contract);
+
if (callback) {
callback(null, contract);
- }
+ }
return contract;
};
/**
+ * Gets the data, which is data to deploy plus constructor params
+ *
+ * @method getData
+ */
+ContractFactory.prototype.getData = function () {
+ var options = {}; // required!
+ var args = Array.prototype.slice.call(arguments);
+
+ var last = args[args.length - 1];
+ if (utils.isObject(last) && !utils.isArray(last)) {
+ options = args.pop();
+ }
+
+ var bytes = encodeConstructorParams(this.abi, args);
+ options.data += bytes;
+
+ return options.data;
+};
+
+/**
* Should be called to create new contract instance
*
* @method Contract
* @param {Array} abi
* @param {Address} contract address
*/
-var Contract = function (abi, address) {
+var Contract = function (eth, abi, address) {
+ this._eth = eth;
+ this.transactionHash = null;
this.address = address;
+ this.abi = abi;
};
-module.exports = contract;
+module.exports = ContractFactory;
-},{"../solidity/coder":7,"../utils/utils":20,"../web3":22,"./allevents":23,"./event":27,"./function":30}],26:[function(require,module,exports){
+},{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file errors.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
@@ -3067,13 +3052,13 @@ module.exports = {
return new Error('Invalid number of input parameters');
},
InvalidConnection: function (host){
- return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +', is it running?');
+ return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
},
InvalidProvider: function () {
- return new Error('Providor not set or invalid');
+ return new Error('Provider not set or invalid');
},
InvalidResponse: function (result){
- var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: '+ result;
+ var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
return new Error(message);
}
};
@@ -3081,22 +3066,22 @@ module.exports = {
},{}],27:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file event.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2014
@@ -3112,7 +3097,8 @@ var watches = require('./methods/watches');
/**
* This prototype should be used to create event filters
*/
-var SolidityEvent = function (json, address) {
+var SolidityEvent = function (requestManager, json, address) {
+ this._requestManager = requestManager;
this._params = json.inputs;
this._name = utils.transformToFullName(json);
this._address = address;
@@ -3166,7 +3152,7 @@ SolidityEvent.prototype.signature = function () {
/**
* Should be used to encode indexed params and options to one final object
- *
+ *
* @method encode
* @param {Object} indexed
* @param {Object} options
@@ -3197,7 +3183,7 @@ SolidityEvent.prototype.encode = function (indexed, options) {
if (value === undefined || value === null) {
return null;
}
-
+
if (utils.isArray(value)) {
return value.map(function (v) {
return '0x' + coder.encodeParam(i.type, v);
@@ -3219,17 +3205,17 @@ SolidityEvent.prototype.encode = function (indexed, options) {
* @return {Object} result object with decoded indexed && not indexed params
*/
SolidityEvent.prototype.decode = function (data) {
-
+
data.data = data.data || '';
data.topics = data.topics || [];
var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
- var indexedParams = coder.decodeParams(this.types(true), indexedData);
+ var indexedParams = coder.decodeParams(this.types(true), indexedData);
var notIndexedData = data.data.slice(2);
var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
-
+
var result = formatters.outputLogFormatter(data);
result.event = this.displayName();
result.address = data.address;
@@ -3264,10 +3250,10 @@ SolidityEvent.prototype.execute = function (indexed, options, callback) {
indexed = {};
}
}
-
+
var o = this.encode(indexed, options);
var formatter = this.decode.bind(this);
- return new Filter(o, watches.eth(), formatter, callback);
+ return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
};
/**
@@ -3288,22 +3274,72 @@ SolidityEvent.prototype.attachToContract = function (contract) {
module.exports = SolidityEvent;
-},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":28,"./formatters":29,"./methods/watches":40}],28:[function(require,module,exports){
+},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":41}],28:[function(require,module,exports){
+var formatters = require('./formatters');
+var utils = require('./../utils/utils');
+var Method = require('./method');
+var Property = require('./property');
+
+// TODO: refactor, so the input params are not altered.
+// it's necessary to make same 'extension' work with multiple providers
+var extend = function (web3) {
+ /* jshint maxcomplexity:5 */
+ var ex = function (extension) {
+
+ var extendedObject;
+ if (extension.property) {
+ if (!web3[extension.property]) {
+ web3[extension.property] = {};
+ }
+ extendedObject = web3[extension.property];
+ } else {
+ extendedObject = web3;
+ }
+
+ if (extension.methods) {
+ extension.methods.forEach(function (method) {
+ method.attachToObject(extendedObject);
+ method.setRequestManager(web3._requestManager);
+ });
+ }
+
+ if (extension.properties) {
+ extension.properties.forEach(function (property) {
+ property.attachToObject(extendedObject);
+ property.setRequestManager(web3._requestManager);
+ });
+ }
+ };
+
+ ex.formatters = formatters;
+ ex.utils = utils;
+ ex.Method = Method;
+ ex.Property = Property;
+
+ return ex;
+};
+
+
+
+module.exports = extend;
+
+
+},{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":43}],29:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file filter.js
* @authors:
@@ -3315,7 +3351,6 @@ module.exports = SolidityEvent;
* @date 2014
*/
-var RequestManager = require('./requestmanager');
var formatters = require('./formatters');
var utils = require('../utils/utils');
@@ -3345,7 +3380,7 @@ var getOptions = function (options) {
if (utils.isString(options)) {
return options;
- }
+ }
options = options || {};
@@ -3355,14 +3390,14 @@ var getOptions = function (options) {
return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
});
- // lazy load
return {
topics: options.topics,
+ from: options.from,
to: options.to,
address: options.address,
fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
- toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
- };
+ toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
+ };
};
/**
@@ -3370,7 +3405,7 @@ Adds the callback and sets up the methods, to iterate over the results.
@method getLogsAtStart
@param {Object} self
-@param {funciton}
+@param {funciton}
*/
var getLogsAtStart = function(self, callback){
// call getFilterLogs for the first watch callback start
@@ -3415,19 +3450,21 @@ var pollFilter = function(self) {
}
};
- RequestManager.getInstance().startPolling({
+ self.requestManager.startPolling({
method: self.implementation.poll.call,
params: [self.filterId],
}, self.filterId, onMessage, self.stopWatching.bind(self));
};
-var Filter = function (options, methods, formatter, callback) {
+var Filter = function (requestManager, options, methods, formatter, callback) {
var self = this;
var implementation = {};
methods.forEach(function (method) {
+ method.setRequestManager(requestManager);
method.attachToObject(implementation);
});
+ this.requestManager = requestManager;
this.options = getOptions(options);
this.implementation = implementation;
this.filterId = null;
@@ -3479,7 +3516,7 @@ Filter.prototype.watch = function (callback) {
};
Filter.prototype.stopWatching = function () {
- RequestManager.getInstance().stopPolling(this.filterId);
+ this.requestManager.stopPolling(this.filterId);
// remove filter async
this.implementation.uninstallFilter(this.filterId, function(){});
this.callbacks = [];
@@ -3519,24 +3556,24 @@ Filter.prototype.get = function (callback) {
module.exports = Filter;
-},{"../utils/utils":20,"./formatters":29,"./requestmanager":43}],29:[function(require,module,exports){
+},{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file formatters.js
* @author Marek Kotewicz <marek@ethdev.com>
* @author Fabian Vogelsteller <fabian@ethdev.com>
@@ -3603,7 +3640,7 @@ var inputCallFormatter = function (options){
options[key] = utils.fromDecimal(options[key]);
});
- return options;
+ return options;
};
/**
@@ -3628,12 +3665,12 @@ var inputTransactionFormatter = function (options){
options[key] = utils.fromDecimal(options[key]);
});
- return options;
+ return options;
};
/**
* Formats the output of a transaction to its proper values
- *
+ *
* @method outputTransactionFormatter
* @param {Object} tx
* @returns {Object}
@@ -3652,7 +3689,7 @@ var outputTransactionFormatter = function (tx){
/**
* Formats the output of a transaction receipt to its proper values
- *
+ *
* @method outputTransactionReceiptFormatter
* @param {Object} receipt
* @returns {Object}
@@ -3678,7 +3715,7 @@ var outputTransactionReceiptFormatter = function (receipt){
* Formats the output of a block to its proper values
*
* @method outputBlockFormatter
- * @param {Object} block
+ * @param {Object} block
* @returns {Object}
*/
var outputBlockFormatter = function(block) {
@@ -3706,7 +3743,7 @@ var outputBlockFormatter = function(block) {
/**
* Formats the output of a log
- *
+ *
* @method outputLogFormatter
* @param {Object} log object
* @returns {Object} log
@@ -3731,7 +3768,7 @@ var outputLogFormatter = function(log) {
*/
var inputPostFormatter = function(post) {
- post.payload = utils.toHex(post.payload);
+ // post.payload = utils.toHex(post.payload);
post.ttl = utils.fromDecimal(post.ttl);
post.workToProve = utils.fromDecimal(post.workToProve);
post.priority = utils.fromDecimal(post.priority);
@@ -3743,10 +3780,11 @@ var inputPostFormatter = function(post) {
// format the following options
post.topics = post.topics.map(function(topic){
- return utils.fromUtf8(topic);
+ // convert only if not hex
+ return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
});
- return post;
+ return post;
};
/**
@@ -3762,19 +3800,19 @@ var outputPostFormatter = function(post){
post.sent = utils.toDecimal(post.sent);
post.ttl = utils.toDecimal(post.ttl);
post.workProved = utils.toDecimal(post.workProved);
- post.payloadRaw = post.payload;
- post.payload = utils.toUtf8(post.payload);
+ // post.payloadRaw = post.payload;
+ // post.payload = utils.toAscii(post.payload);
- if (utils.isJson(post.payload)) {
- post.payload = JSON.parse(post.payload);
- }
+ // if (utils.isJson(post.payload)) {
+ // post.payload = JSON.parse(post.payload);
+ // }
// format the following options
if (!post.topics) {
post.topics = [];
}
post.topics = post.topics.map(function(topic){
- return utils.toUtf8(topic);
+ return utils.toAscii(topic);
});
return post;
@@ -3819,22 +3857,22 @@ module.exports = {
};
-},{"../utils/config":18,"../utils/utils":20,"./iban":32}],30:[function(require,module,exports){
+},{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file function.js
@@ -3842,7 +3880,6 @@ module.exports = {
* @date 2015
*/
-var web3 = require('../web3');
var coder = require('../solidity/coder');
var utils = require('../utils/utils');
var formatters = require('./formatters');
@@ -3851,7 +3888,8 @@ var sha3 = require('../utils/sha3');
/**
* This prototype should be used to call/sendTransaction to solidity functions
*/
-var SolidityFunction = function (json, address) {
+var SolidityFunction = function (eth, json, address) {
+ this._eth = eth;
this._inputTypes = json.inputs.map(function (i) {
return i.type;
});
@@ -3931,12 +3969,12 @@ SolidityFunction.prototype.call = function () {
if (!callback) {
- var output = web3.eth.call(payload, defaultBlock);
+ var output = this._eth.call(payload, defaultBlock);
return this.unpackOutput(output);
- }
-
+ }
+
var self = this;
- web3.eth.call(payload, defaultBlock, function (error, output) {
+ this._eth.call(payload, defaultBlock, function (error, output) {
callback(error, self.unpackOutput(output));
});
};
@@ -3945,7 +3983,6 @@ SolidityFunction.prototype.call = function () {
* Should be used to sendTransaction to solidity function
*
* @method sendTransaction
- * @param {Object} options
*/
SolidityFunction.prototype.sendTransaction = function () {
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
@@ -3953,17 +3990,16 @@ SolidityFunction.prototype.sendTransaction = function () {
var payload = this.toPayload(args);
if (!callback) {
- return web3.eth.sendTransaction(payload);
+ return this._eth.sendTransaction(payload);
}
- web3.eth.sendTransaction(payload, callback);
+ this._eth.sendTransaction(payload, callback);
};
/**
* Should be used to estimateGas of solidity function
*
* @method estimateGas
- * @param {Object} options
*/
SolidityFunction.prototype.estimateGas = function () {
var args = Array.prototype.slice.call(arguments);
@@ -3971,10 +4007,23 @@ SolidityFunction.prototype.estimateGas = function () {
var payload = this.toPayload(args);
if (!callback) {
- return web3.eth.estimateGas(payload);
+ return this._eth.estimateGas(payload);
}
- web3.eth.estimateGas(payload, callback);
+ this._eth.estimateGas(payload, callback);
+};
+
+/**
+ * Return the encoded data of the call
+ *
+ * @method getData
+ * @return {String} the encoded data
+ */
+SolidityFunction.prototype.getData = function () {
+ var args = Array.prototype.slice.call(arguments);
+ var payload = this.toPayload(args);
+
+ return payload.data;
};
/**
@@ -4008,11 +4057,11 @@ SolidityFunction.prototype.request = function () {
var callback = this.extractCallback(args);
var payload = this.toPayload(args);
var format = this.unpackOutput.bind(this);
-
+
return {
method: this._constant ? 'eth_call' : 'eth_sendTransaction',
callback: callback,
- params: [payload],
+ params: [payload],
format: format
};
};
@@ -4046,6 +4095,7 @@ SolidityFunction.prototype.attachToContract = function (contract) {
execute.call = this.call.bind(this);
execute.sendTransaction = this.sendTransaction.bind(this);
execute.estimateGas = this.estimateGas.bind(this);
+ execute.getData = this.getData.bind(this);
var displayName = this.displayName();
if (!contract[displayName]) {
contract[displayName] = execute;
@@ -4056,22 +4106,22 @@ SolidityFunction.prototype.attachToContract = function (contract) {
module.exports = SolidityFunction;
-},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"../web3":22,"./formatters":29}],31:[function(require,module,exports){
+},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file httpprovider.js
* @authors:
@@ -4143,7 +4193,7 @@ HttpProvider.prototype.send = function (payload) {
try {
result = JSON.parse(result);
} catch(e) {
- throw errors.InvalidResponse(request.responseText);
+ throw errors.InvalidResponse(request.responseText);
}
return result;
@@ -4157,7 +4207,7 @@ HttpProvider.prototype.send = function (payload) {
* @param {Function} callback triggered on end with (err, result)
*/
HttpProvider.prototype.sendAsync = function (payload, callback) {
- var request = this.prepareRequest(true);
+ var request = this.prepareRequest(true);
request.onreadystatechange = function() {
if (request.readyState === 4) {
@@ -4167,13 +4217,13 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
try {
result = JSON.parse(result);
} catch(e) {
- error = errors.InvalidResponse(request.responseText);
+ error = errors.InvalidResponse(request.responseText);
}
callback(error, result);
}
};
-
+
try {
request.send(JSON.stringify(payload));
} catch(error) {
@@ -4204,24 +4254,24 @@ HttpProvider.prototype.isConnected = function() {
module.exports = HttpProvider;
-},{"./errors":26,"xmlhttprequest":17}],32:[function(require,module,exports){
+},{"./errors":26,"xmlhttprequest":17}],33:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file iban.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
@@ -4421,7 +4471,7 @@ Iban.prototype.address = function () {
var base36 = this._iban.substr(4);
var asBn = new BigNumber(base36, 36);
return padLeft(asBn.toString(16), 20);
- }
+ }
return '';
};
@@ -4433,22 +4483,22 @@ Iban.prototype.toString = function () {
module.exports = Iban;
-},{"bignumber.js":"bignumber.js"}],33:[function(require,module,exports){
+},{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file ipcprovider.js
* @authors:
@@ -4461,23 +4511,12 @@ module.exports = Iban;
var utils = require('../utils/utils');
var errors = require('./errors');
-var errorTimeout = function (method, id) {
- var err = {
- "jsonrpc": "2.0",
- "error": {
- "code": -32603,
- "message": "IPC Request timed out for method \'" + method + "\'"
- },
- "id": id
- };
- return JSON.stringify(err);
-};
var IpcProvider = function (path, net) {
var _this = this;
this.responseCallbacks = {};
this.path = path;
-
+
this.connection = net.connect({path: this.path});
this.connection.on('error', function(e){
@@ -4487,7 +4526,7 @@ var IpcProvider = function (path, net) {
this.connection.on('end', function(){
_this._timeout();
- });
+ });
// LISTEN FOR CONNECTION RESPONSES
@@ -4526,7 +4565,7 @@ Will parse the response and make an array out of it.
IpcProvider.prototype._parseResponse = function(data) {
var _this = this,
returnValues = [];
-
+
// DE-CHUNKER
var dechunkedData = data
.replace(/\}\{/g,'}|--|{') // }{
@@ -4594,7 +4633,7 @@ Timeout all requests when the end/error event is fired
IpcProvider.prototype._timeout = function() {
for(var key in this.responseCallbacks) {
if(this.responseCallbacks.hasOwnProperty(key)){
- this.responseCallbacks[key](errorTimeout(this.responseCallbacks[key].method, key));
+ this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
delete this.responseCallbacks[key];
}
}
@@ -4630,7 +4669,7 @@ IpcProvider.prototype.send = function (payload) {
try {
result = JSON.parse(data);
} catch(e) {
- throw errors.InvalidResponse(data);
+ throw errors.InvalidResponse(data);
}
return result;
@@ -4653,22 +4692,22 @@ IpcProvider.prototype.sendAsync = function (payload, callback) {
module.exports = IpcProvider;
-},{"../utils/utils":20,"./errors":26}],34:[function(require,module,exports){
+},{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file jsonrpc.js
* @authors:
@@ -4746,22 +4785,22 @@ Jsonrpc.prototype.toBatchPayload = function (messages) {
module.exports = Jsonrpc;
-},{}],35:[function(require,module,exports){
+},{}],36:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file method.js
@@ -4769,7 +4808,6 @@ module.exports = Jsonrpc;
* @date 2015
*/
-var RequestManager = require('./requestmanager');
var utils = require('../utils/utils');
var errors = require('./errors');
@@ -4779,6 +4817,11 @@ var Method = function (options) {
this.params = options.params || 0;
this.inputFormatter = options.inputFormatter;
this.outputFormatter = options.outputFormatter;
+ this.requestManager = null;
+};
+
+Method.prototype.setRequestManager = function (rm) {
+ this.requestManager = rm;
};
/**
@@ -4807,7 +4850,7 @@ Method.prototype.extractCallback = function (args) {
/**
* Should be called to check if the number of arguments is correct
- *
+ *
* @method validateArgs
* @param {Array} arguments
* @throws {Error} if it is not
@@ -4820,7 +4863,7 @@ Method.prototype.validateArgs = function (args) {
/**
* Should be called to format input args of method
- *
+ *
* @method formatInput
* @param {Array}
* @return {Array}
@@ -4847,26 +4890,6 @@ Method.prototype.formatOutput = function (result) {
};
/**
- * Should attach function to method
- *
- * @method attachToObject
- * @param {Object}
- * @param {Function}
- */
-Method.prototype.attachToObject = function (obj) {
- var func = this.send.bind(this);
- func.request = this.request.bind(this);
- func.call = this.call; // that's ugly. filter.js uses it
- var name = this.name.split('.');
- if (name.length > 1) {
- obj[name[0]] = obj[name[0]] || {};
- obj[name[0]][name[1]] = func;
- } else {
- obj[name[0]] = func;
- }
-};
-
-/**
* Should create payload from given input args
*
* @method toPayload
@@ -4886,6 +4909,33 @@ Method.prototype.toPayload = function (args) {
};
};
+Method.prototype.attachToObject = function (obj) {
+ var func = this.buildCall();
+ func.call = this.call; // TODO!!! that's ugly. filter.js uses it
+ var name = this.name.split('.');
+ if (name.length > 1) {
+ obj[name[0]] = obj[name[0]] || {};
+ obj[name[0]][name[1]] = func;
+ } else {
+ obj[name[0]] = func;
+ }
+};
+
+Method.prototype.buildCall = function() {
+ var method = this;
+ var send = function () {
+ var payload = method.toPayload(Array.prototype.slice.call(arguments));
+ if (payload.callback) {
+ return method.requestManager.sendAsync(payload, function (err, result) {
+ payload.callback(err, method.formatOutput(result));
+ });
+ }
+ return method.formatOutput(method.requestManager.send(payload));
+ };
+ send.request = this.request.bind(this);
+ return send;
+};
+
/**
* Should be called to create pure JSONRPC request which can be used in batch request
*
@@ -4899,43 +4949,25 @@ Method.prototype.request = function () {
return payload;
};
-/**
- * Should send request to the API
- *
- * @method send
- * @param list of params
- * @return result
- */
-Method.prototype.send = function () {
- var payload = this.toPayload(Array.prototype.slice.call(arguments));
- if (payload.callback) {
- var self = this;
- return RequestManager.getInstance().sendAsync(payload, function (err, result) {
- payload.callback(err, self.formatOutput(result));
- });
- }
- return this.formatOutput(RequestManager.getInstance().send(payload));
-};
-
module.exports = Method;
-},{"../utils/utils":20,"./errors":26,"./requestmanager":43}],36:[function(require,module,exports){
+},{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file db.js
* @authors:
@@ -4945,55 +4977,65 @@ module.exports = Method;
var Method = require('../method');
-var putString = new Method({
- name: 'putString',
- call: 'db_putString',
- params: 3
-});
+var DB = function (web3) {
+ this._requestManager = web3._requestManager;
+ var self = this;
+
+ methods().forEach(function(method) {
+ method.attachToObject(self);
+ method.setRequestManager(web3._requestManager);
+ });
+};
-var getString = new Method({
- name: 'getString',
- call: 'db_getString',
- params: 2
-});
+var methods = function () {
+ var putString = new Method({
+ name: 'putString',
+ call: 'db_putString',
+ params: 3
+ });
-var putHex = new Method({
- name: 'putHex',
- call: 'db_putHex',
- params: 3
-});
+ var getString = new Method({
+ name: 'getString',
+ call: 'db_getString',
+ params: 2
+ });
-var getHex = new Method({
- name: 'getHex',
- call: 'db_getHex',
- params: 2
-});
+ var putHex = new Method({
+ name: 'putHex',
+ call: 'db_putHex',
+ params: 3
+ });
-var methods = [
- putString, getString, putHex, getHex
-];
+ var getHex = new Method({
+ name: 'getHex',
+ call: 'db_getHex',
+ params: 2
+ });
-module.exports = {
- methods: methods
+ return [
+ putString, getString, putHex, getHex
+ ];
};
-},{"../method":35}],37:[function(require,module,exports){
+module.exports = DB;
+
+},{"../method":36}],38:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file eth.js
@@ -5002,38 +5044,20 @@ module.exports = {
* @date 2015
*/
-/**
- * Web3
- *
- * @module web3
- */
-
-/**
- * Eth methods and properties
- *
- * An example method object can look as follows:
- *
- * {
- * name: 'getBlock',
- * call: blockCall,
- * params: 2,
- * outputFormatter: formatters.outputBlockFormatter,
- * inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter
- * utils.toHex, // formats paramter 1
- * function(param){ return !!param; } // formats paramter 2
- * ]
- * },
- *
- * @class [web3] eth
- * @constructor
- */
-
"use strict";
var formatters = require('../formatters');
var utils = require('../../utils/utils');
var Method = require('../method');
var Property = require('../property');
+var c = require('../../utils/config');
+var Contract = require('../contract');
+var watches = require('./watches');
+var Filter = require('../filter');
+var IsSyncing = require('../syncing');
+var namereg = require('../namereg');
+var Iban = require('../iban');
+var transfer = require('../transfer');
var blockCall = function (args) {
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
@@ -5055,243 +5079,300 @@ var uncleCountCall = function (args) {
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
};
-/// @returns an array of objects describing web3.eth api methods
+function Eth(web3) {
+ this._requestManager = web3._requestManager;
-var getBalance = new Method({
- name: 'getBalance',
- call: 'eth_getBalance',
- params: 2,
- inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
- outputFormatter: formatters.outputBigNumberFormatter
-});
+ var self = this;
-var getStorageAt = new Method({
- name: 'getStorageAt',
- call: 'eth_getStorageAt',
- params: 3,
- inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
-});
+ methods().forEach(function(method) {
+ method.attachToObject(self);
+ method.setRequestManager(self._requestManager);
+ });
-var getCode = new Method({
- name: 'getCode',
- call: 'eth_getCode',
- params: 2,
- inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
-});
+ properties().forEach(function(p) {
+ p.attachToObject(self);
+ p.setRequestManager(self._requestManager);
+ });
-var getBlock = new Method({
- name: 'getBlock',
- call: blockCall,
- params: 2,
- inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
- outputFormatter: formatters.outputBlockFormatter
-});
-var getUncle = new Method({
- name: 'getUncle',
- call: uncleCall,
- params: 2,
- inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
- outputFormatter: formatters.outputBlockFormatter,
+ this.iban = Iban;
+ this.sendIBANTransaction = transfer.bind(null, this);
+}
+Object.defineProperty(Eth.prototype, 'defaultBlock', {
+ get: function () {
+ return c.defaultBlock;
+ },
+ set: function (val) {
+ c.defaultBlock = val;
+ return val;
+ }
});
-var getCompilers = new Method({
- name: 'getCompilers',
- call: 'eth_getCompilers',
- params: 0
+Object.defineProperty(Eth.prototype, 'defaultAccount', {
+ get: function () {
+ return c.defaultAccount;
+ },
+ set: function (val) {
+ c.defaultAccount = val;
+ return val;
+ }
});
-var getBlockTransactionCount = new Method({
- name: 'getBlockTransactionCount',
- call: getBlockTransactionCountCall,
- params: 1,
- inputFormatter: [formatters.inputBlockNumberFormatter],
- outputFormatter: utils.toDecimal
-});
+var methods = function () {
+ var getBalance = new Method({
+ name: 'getBalance',
+ call: 'eth_getBalance',
+ params: 2,
+ inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
+ outputFormatter: formatters.outputBigNumberFormatter
+ });
-var getBlockUncleCount = new Method({
- name: 'getBlockUncleCount',
- call: uncleCountCall,
- params: 1,
- inputFormatter: [formatters.inputBlockNumberFormatter],
- outputFormatter: utils.toDecimal
-});
+ var getStorageAt = new Method({
+ name: 'getStorageAt',
+ call: 'eth_getStorageAt',
+ params: 3,
+ inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
+ });
-var getTransaction = new Method({
- name: 'getTransaction',
- call: 'eth_getTransactionByHash',
- params: 1,
- outputFormatter: formatters.outputTransactionFormatter
-});
+ var getCode = new Method({
+ name: 'getCode',
+ call: 'eth_getCode',
+ params: 2,
+ inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
+ });
-var getTransactionFromBlock = new Method({
- name: 'getTransactionFromBlock',
- call: transactionFromBlockCall,
- params: 2,
- inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
- outputFormatter: formatters.outputTransactionFormatter
-});
+ var getBlock = new Method({
+ name: 'getBlock',
+ call: blockCall,
+ params: 2,
+ inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
+ outputFormatter: formatters.outputBlockFormatter
+ });
-var getTransactionReceipt = new Method({
- name: 'getTransactionReceipt',
- call: 'eth_getTransactionReceipt',
- params: 1,
- outputFormatter: formatters.outputTransactionReceiptFormatter
-});
+ var getUncle = new Method({
+ name: 'getUncle',
+ call: uncleCall,
+ params: 2,
+ inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
+ outputFormatter: formatters.outputBlockFormatter,
-var getTransactionCount = new Method({
- name: 'getTransactionCount',
- call: 'eth_getTransactionCount',
- params: 2,
- inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
- outputFormatter: utils.toDecimal
-});
+ });
-var sendRawTransaction = new Method({
- name: 'sendRawTransaction',
- call: 'eth_sendRawTransaction',
- params: 1,
- inputFormatter: [null]
-});
+ var getCompilers = new Method({
+ name: 'getCompilers',
+ call: 'eth_getCompilers',
+ params: 0
+ });
-var sendTransaction = new Method({
- name: 'sendTransaction',
- call: 'eth_sendTransaction',
- params: 1,
- inputFormatter: [formatters.inputTransactionFormatter]
-});
+ var getBlockTransactionCount = new Method({
+ name: 'getBlockTransactionCount',
+ call: getBlockTransactionCountCall,
+ params: 1,
+ inputFormatter: [formatters.inputBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+ });
-var call = new Method({
- name: 'call',
- call: 'eth_call',
- params: 2,
- inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
-});
+ var getBlockUncleCount = new Method({
+ name: 'getBlockUncleCount',
+ call: uncleCountCall,
+ params: 1,
+ inputFormatter: [formatters.inputBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+ });
-var estimateGas = new Method({
- name: 'estimateGas',
- call: 'eth_estimateGas',
- params: 1,
- inputFormatter: [formatters.inputCallFormatter],
- outputFormatter: utils.toDecimal
-});
+ var getTransaction = new Method({
+ name: 'getTransaction',
+ call: 'eth_getTransactionByHash',
+ params: 1,
+ outputFormatter: formatters.outputTransactionFormatter
+ });
-var compileSolidity = new Method({
- name: 'compile.solidity',
- call: 'eth_compileSolidity',
- params: 1
-});
+ var getTransactionFromBlock = new Method({
+ name: 'getTransactionFromBlock',
+ call: transactionFromBlockCall,
+ params: 2,
+ inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
+ outputFormatter: formatters.outputTransactionFormatter
+ });
-var compileLLL = new Method({
- name: 'compile.lll',
- call: 'eth_compileLLL',
- params: 1
-});
+ var getTransactionReceipt = new Method({
+ name: 'getTransactionReceipt',
+ call: 'eth_getTransactionReceipt',
+ params: 1,
+ outputFormatter: formatters.outputTransactionReceiptFormatter
+ });
-var compileSerpent = new Method({
- name: 'compile.serpent',
- call: 'eth_compileSerpent',
- params: 1
-});
+ var getTransactionCount = new Method({
+ name: 'getTransactionCount',
+ call: 'eth_getTransactionCount',
+ params: 2,
+ inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+ });
-var submitWork = new Method({
- name: 'submitWork',
- call: 'eth_submitWork',
- params: 3
-});
+ var sendRawTransaction = new Method({
+ name: 'sendRawTransaction',
+ call: 'eth_sendRawTransaction',
+ params: 1,
+ inputFormatter: [null]
+ });
-var getWork = new Method({
- name: 'getWork',
- call: 'eth_getWork',
- params: 0
-});
+ var sendTransaction = new Method({
+ name: 'sendTransaction',
+ call: 'eth_sendTransaction',
+ params: 1,
+ inputFormatter: [formatters.inputTransactionFormatter]
+ });
-var methods = [
- getBalance,
- getStorageAt,
- getCode,
- getBlock,
- getUncle,
- getCompilers,
- getBlockTransactionCount,
- getBlockUncleCount,
- getTransaction,
- getTransactionFromBlock,
- getTransactionReceipt,
- getTransactionCount,
- call,
- estimateGas,
- sendRawTransaction,
- sendTransaction,
- compileSolidity,
- compileLLL,
- compileSerpent,
- submitWork,
- getWork
-];
+ var call = new Method({
+ name: 'call',
+ call: 'eth_call',
+ params: 2,
+ inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
+ });
-/// @returns an array of objects describing web3.eth api properties
+ var estimateGas = new Method({
+ name: 'estimateGas',
+ call: 'eth_estimateGas',
+ params: 1,
+ inputFormatter: [formatters.inputCallFormatter],
+ outputFormatter: utils.toDecimal
+ });
+
+ var compileSolidity = new Method({
+ name: 'compile.solidity',
+ call: 'eth_compileSolidity',
+ params: 1
+ });
+
+ var compileLLL = new Method({
+ name: 'compile.lll',
+ call: 'eth_compileLLL',
+ params: 1
+ });
+ var compileSerpent = new Method({
+ name: 'compile.serpent',
+ call: 'eth_compileSerpent',
+ params: 1
+ });
+ var submitWork = new Method({
+ name: 'submitWork',
+ call: 'eth_submitWork',
+ params: 3
+ });
-var properties = [
- new Property({
- name: 'coinbase',
- getter: 'eth_coinbase'
- }),
- new Property({
- name: 'mining',
- getter: 'eth_mining'
- }),
- new Property({
- name: 'hashrate',
- getter: 'eth_hashrate',
- outputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'syncing',
- getter: 'eth_syncing',
- outputFormatter: formatters.outputSyncingFormatter
- }),
- new Property({
- name: 'gasPrice',
- getter: 'eth_gasPrice',
- outputFormatter: formatters.outputBigNumberFormatter
- }),
- new Property({
- name: 'accounts',
- getter: 'eth_accounts'
- }),
- new Property({
- name: 'blockNumber',
- getter: 'eth_blockNumber',
- outputFormatter: utils.toDecimal
- })
-];
+ var getWork = new Method({
+ name: 'getWork',
+ call: 'eth_getWork',
+ params: 0
+ });
-module.exports = {
- methods: methods,
- properties: properties
+ return [
+ getBalance,
+ getStorageAt,
+ getCode,
+ getBlock,
+ getUncle,
+ getCompilers,
+ getBlockTransactionCount,
+ getBlockUncleCount,
+ getTransaction,
+ getTransactionFromBlock,
+ getTransactionReceipt,
+ getTransactionCount,
+ call,
+ estimateGas,
+ sendRawTransaction,
+ sendTransaction,
+ compileSolidity,
+ compileLLL,
+ compileSerpent,
+ submitWork,
+ getWork
+ ];
};
-},{"../../utils/utils":20,"../formatters":29,"../method":35,"../property":42}],38:[function(require,module,exports){
+var properties = function () {
+ return [
+ new Property({
+ name: 'coinbase',
+ getter: 'eth_coinbase'
+ }),
+ new Property({
+ name: 'mining',
+ getter: 'eth_mining'
+ }),
+ new Property({
+ name: 'hashrate',
+ getter: 'eth_hashrate',
+ outputFormatter: utils.toDecimal
+ }),
+ new Property({
+ name: 'syncing',
+ getter: 'eth_syncing',
+ outputFormatter: formatters.outputSyncingFormatter
+ }),
+ new Property({
+ name: 'gasPrice',
+ getter: 'eth_gasPrice',
+ outputFormatter: formatters.outputBigNumberFormatter
+ }),
+ new Property({
+ name: 'accounts',
+ getter: 'eth_accounts'
+ }),
+ new Property({
+ name: 'blockNumber',
+ getter: 'eth_blockNumber',
+ outputFormatter: utils.toDecimal
+ })
+ ];
+};
+
+Eth.prototype.contract = function (abi) {
+ var factory = new Contract(this, abi);
+ return factory;
+};
+
+Eth.prototype.filter = function (fil, callback) {
+ return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
+};
+
+Eth.prototype.namereg = function () {
+ return this.contract(namereg.global.abi).at(namereg.global.address);
+};
+
+Eth.prototype.icapNamereg = function () {
+ return this.contract(namereg.icap.abi).at(namereg.icap.address);
+};
+
+Eth.prototype.isSyncing = function (callback) {
+ return new IsSyncing(this._requestManager, callback);
+};
+
+module.exports = Eth;
+
+
+},{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":42,"../property":43,"../syncing":46,"../transfer":47,"./watches":41}],39:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file eth.js
* @authors:
@@ -5302,46 +5383,50 @@ module.exports = {
var utils = require('../../utils/utils');
var Property = require('../property');
-/// @returns an array of objects describing web3.eth api methods
-var methods = [
-];
+var Net = function (web3) {
+ this._requestManager = web3._requestManager;
-/// @returns an array of objects describing web3.eth api properties
-var properties = [
- new Property({
- name: 'listening',
- getter: 'net_listening'
- }),
- new Property({
- name: 'peerCount',
- getter: 'net_peerCount',
- outputFormatter: utils.toDecimal
- })
-];
+ var self = this;
+ properties().forEach(function(p) {
+ p.attachToObject(self);
+ p.setRequestManager(web3._requestManager);
+ });
+};
-module.exports = {
- methods: methods,
- properties: properties
+/// @returns an array of objects describing web3.eth api properties
+var properties = function () {
+ return [
+ new Property({
+ name: 'listening',
+ getter: 'net_listening'
+ }),
+ new Property({
+ name: 'peerCount',
+ getter: 'net_peerCount',
+ outputFormatter: utils.toDecimal
+ })
+ ];
};
+module.exports = Net;
-},{"../../utils/utils":20,"../property":42}],39:[function(require,module,exports){
+},{"../../utils/utils":20,"../property":43}],40:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file shh.js
* @authors:
@@ -5351,67 +5436,85 @@ module.exports = {
var Method = require('../method');
var formatters = require('../formatters');
+var Filter = require('../filter');
+var watches = require('./watches');
-var post = new Method({
- name: 'post',
- call: 'shh_post',
- params: 1,
- inputFormatter: [formatters.inputPostFormatter]
-});
+var Shh = function (web3) {
+ this._requestManager = web3._requestManager;
-var newIdentity = new Method({
- name: 'newIdentity',
- call: 'shh_newIdentity',
- params: 0
-});
+ var self = this;
-var hasIdentity = new Method({
- name: 'hasIdentity',
- call: 'shh_hasIdentity',
- params: 1
-});
+ methods().forEach(function(method) {
+ method.attachToObject(self);
+ method.setRequestManager(self._requestManager);
+ });
+};
-var newGroup = new Method({
- name: 'newGroup',
- call: 'shh_newGroup',
- params: 0
-});
+Shh.prototype.filter = function (fil, callback) {
+ return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
+};
-var addToGroup = new Method({
- name: 'addToGroup',
- call: 'shh_addToGroup',
- params: 0
-});
+var methods = function () {
-var methods = [
- post,
- newIdentity,
- hasIdentity,
- newGroup,
- addToGroup
-];
+ var post = new Method({
+ name: 'post',
+ call: 'shh_post',
+ params: 1,
+ inputFormatter: [formatters.inputPostFormatter]
+ });
-module.exports = {
- methods: methods
+ var newIdentity = new Method({
+ name: 'newIdentity',
+ call: 'shh_newIdentity',
+ params: 0
+ });
+
+ var hasIdentity = new Method({
+ name: 'hasIdentity',
+ call: 'shh_hasIdentity',
+ params: 1
+ });
+
+ var newGroup = new Method({
+ name: 'newGroup',
+ call: 'shh_newGroup',
+ params: 0
+ });
+
+ var addToGroup = new Method({
+ name: 'addToGroup',
+ call: 'shh_addToGroup',
+ params: 0
+ });
+
+ return [
+ post,
+ newIdentity,
+ hasIdentity,
+ newGroup,
+ addToGroup
+ ];
};
+module.exports = Shh;
-},{"../formatters":29,"../method":35}],40:[function(require,module,exports){
+
+},{"../filter":29,"../formatters":30,"../method":36,"./watches":41}],41:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file watches.js
* @authors:
@@ -5512,58 +5615,63 @@ module.exports = {
};
-},{"../method":35}],41:[function(require,module,exports){
+},{"../method":36}],42:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file namereg.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
-var contract = require('./contract');
var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
-var ibanNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
+var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
module.exports = {
- namereg: contract(globalRegistrarAbi).at(globalNameregAddress),
- ibanNamereg: contract(icapRegistrarAbi).at(ibanNameregAddress)
+ global: {
+ abi: globalRegistrarAbi,
+ address: globalNameregAddress
+ },
+ icap: {
+ abi: icapRegistrarAbi,
+ address: icapNameregAddress
+ }
};
-},{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2,"./contract":25}],42:[function(require,module,exports){
+},{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],43:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file property.js
@@ -5572,7 +5680,6 @@ module.exports = {
* @date 2015
*/
-var RequestManager = require('./requestmanager');
var utils = require('../utils/utils');
var Property = function (options) {
@@ -5581,11 +5688,16 @@ var Property = function (options) {
this.setter = options.setter;
this.outputFormatter = options.outputFormatter;
this.inputFormatter = options.inputFormatter;
+ this.requestManager = null;
+};
+
+Property.prototype.setRequestManager = function (rm) {
+ this.requestManager = rm;
};
/**
* Should be called to format input args of method
- *
+ *
* @method formatInput
* @param {Array}
* @return {Array}
@@ -5618,16 +5730,17 @@ Property.prototype.extractCallback = function (args) {
}
};
+
/**
* Should attach function to method
- *
+ *
* @method attachToObject
* @param {Object}
* @param {Function}
*/
Property.prototype.attachToObject = function (obj) {
var proto = {
- get: this.get.bind(this),
+ get: this.buildGet()
};
var names = this.name.split('.');
@@ -5639,45 +5752,33 @@ Property.prototype.attachToObject = function (obj) {
}
Object.defineProperty(obj, name, proto);
+ obj[asyncGetterName(name)] = this.buildAsyncGet();
+};
- var toAsyncName = function (prefix, name) {
- return prefix + name.charAt(0).toUpperCase() + name.slice(1);
- };
-
- var func = this.getAsync.bind(this);
- func.request = this.request.bind(this);
-
- obj[toAsyncName('get', name)] = func;
+var asyncGetterName = function (name) {
+ return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
};
-/**
- * Should be used to get value of the property
- *
- * @method get
- * @return {Object} value of the property
- */
-Property.prototype.get = function () {
- return this.formatOutput(RequestManager.getInstance().send({
- method: this.getter
- }));
+Property.prototype.buildGet = function () {
+ var property = this;
+ return function get() {
+ return property.formatOutput(property.requestManager.send({
+ method: property.getter
+ }));
+ };
};
-/**
- * Should be used to asynchrounously get value of property
- *
- * @method getAsync
- * @param {Function}
- */
-Property.prototype.getAsync = function (callback) {
- var self = this;
- RequestManager.getInstance().sendAsync({
- method: this.getter
- }, function (err, result) {
- if (err) {
- return callback(err);
- }
- callback(err, self.formatOutput(result));
- });
+Property.prototype.buildAsyncGet = function () {
+ var property = this;
+ var get = function (callback) {
+ property.requestManager.sendAsync({
+ method: property.getter
+ }, function (err, result) {
+ callback(err, property.formatOutput(result));
+ });
+ };
+ get.request = this.request.bind(this);
+ return get;
};
/**
@@ -5700,24 +5801,24 @@ Property.prototype.request = function () {
module.exports = Property;
-},{"../utils/utils":20,"./requestmanager":43}],43:[function(require,module,exports){
+},{"../utils/utils":20}],44:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file requestmanager.js
* @author Jeffrey Wilcke <jeff@ethdev.com>
* @author Marek Kotewicz <marek@ethdev.com>
@@ -5739,24 +5840,9 @@ var errors = require('./errors');
* Singleton
*/
var RequestManager = function (provider) {
- // singleton pattern
- if (arguments.callee._singletonInstance) {
- return arguments.callee._singletonInstance;
- }
- arguments.callee._singletonInstance = this;
-
this.provider = provider;
this.polls = {};
this.timeout = null;
- this.isPolling = false;
-};
-
-/**
- * @return {RequestManager} singleton
- */
-RequestManager.getInstance = function () {
- var instance = new RequestManager();
- return instance;
};
/**
@@ -5799,7 +5885,7 @@ RequestManager.prototype.sendAsync = function (data, callback) {
if (err) {
return callback(err);
}
-
+
if (!Jsonrpc.getInstance().isValidResponse(result)) {
return callback(errors.InvalidResponse(result));
}
@@ -5832,7 +5918,7 @@ RequestManager.prototype.sendBatch = function (data, callback) {
}
callback(err, results);
- });
+ });
};
/**
@@ -5843,11 +5929,6 @@ RequestManager.prototype.sendBatch = function (data, callback) {
*/
RequestManager.prototype.setProvider = function (p) {
this.provider = p;
-
- if (this.provider && !this.isPolling) {
- this.poll();
- this.isPolling = true;
- }
};
/**
@@ -5863,6 +5944,12 @@ RequestManager.prototype.setProvider = function (p) {
*/
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
+
+
+ // start polling
+ if (!this.timeout) {
+ this.poll();
+ }
};
/**
@@ -5873,6 +5960,12 @@ RequestManager.prototype.startPolling = function (data, pollId, callback, uninst
*/
RequestManager.prototype.stopPolling = function (pollId) {
delete this.polls[pollId];
+
+ // stop polling
+ if(Object.keys(this.polls).length === 0 && this.timeout) {
+ clearTimeout(this.timeout);
+ this.timeout = null;
+ }
};
/**
@@ -5881,6 +5974,8 @@ RequestManager.prototype.stopPolling = function (pollId) {
* @method reset
*/
RequestManager.prototype.reset = function (keepIsSyncing) {
+ /*jshint maxcomplexity:5 */
+
for (var key in this.polls) {
// remove all polls, except sync polls,
// they need to be removed manually by calling syncing.stopWatching()
@@ -5890,11 +5985,11 @@ RequestManager.prototype.reset = function (keepIsSyncing) {
}
}
- if (this.timeout) {
+ // stop polling
+ if(Object.keys(this.polls).length === 0 && this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
- this.poll();
};
/**
@@ -5927,7 +6022,7 @@ RequestManager.prototype.poll = function () {
}
var payload = Jsonrpc.getInstance().toBatchPayload(pollsData);
-
+
// map the request id to they poll id
var pollsIdMap = {};
payload.forEach(function(load, index){
@@ -5957,7 +6052,7 @@ RequestManager.prototype.poll = function () {
} else
return false;
}).filter(function (result) {
- return !!result;
+ return !!result;
}).filter(function (result) {
var valid = Jsonrpc.getInstance().isValidResponse(result);
if (!valid) {
@@ -5973,22 +6068,33 @@ RequestManager.prototype.poll = function () {
module.exports = RequestManager;
-},{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":34}],44:[function(require,module,exports){
+},{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],45:[function(require,module,exports){
+
+
+var Settings = function () {
+ this.defaultBlock = 'latest';
+ this.defaultAccount = undefined;
+};
+
+module.exports = Settings;
+
+
+},{}],46:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file syncing.js
* @authors:
@@ -5996,12 +6102,10 @@ module.exports = RequestManager;
* @date 2015
*/
-var RequestManager = require('./requestmanager');
-var Method = require('./method');
var formatters = require('./formatters');
var utils = require('../utils/utils');
-
+var count = 1;
/**
Adds the callback and sets up the methods, to iterate over the results.
@@ -6010,7 +6114,6 @@ Adds the callback and sets up the methods, to iterate over the results.
@param {Object} self
*/
var pollSyncing = function(self) {
- var lastSyncState = false;
var onMessage = function (error, sync) {
if (error) {
@@ -6019,44 +6122,39 @@ var pollSyncing = function(self) {
});
}
- if(utils.isObject(sync))
- sync = self.implementation.outputFormatter(sync);
+ if(utils.isObject(sync) && sync.startingBlock)
+ sync = formatters.outputSyncingFormatter(sync);
self.callbacks.forEach(function (callback) {
- if(lastSyncState !== sync) {
-
+ if (self.lastSyncState !== sync) {
+
// call the callback with true first so the app can stop anything, before receiving the sync data
- if(!lastSyncState && utils.isObject(sync))
+ if(!self.lastSyncState && utils.isObject(sync))
callback(null, true);
-
+
// call on the next CPU cycle, so the actions of the sync stop can be processes first
setTimeout(function() {
callback(null, sync);
- }, 1);
-
- lastSyncState = sync;
+ }, 0);
+
+ self.lastSyncState = sync;
}
});
};
- RequestManager.getInstance().startPolling({
- method: self.implementation.call,
+ self.requestManager.startPolling({
+ method: 'eth_syncing',
params: [],
}, self.pollId, onMessage, self.stopWatching.bind(self));
};
-var IsSyncing = function (callback) {
- this.pollId = 'syncPoll_'+ Math.floor(Math.random() * 1000);
+var IsSyncing = function (requestManager, callback) {
+ this.requestManager = requestManager;
+ this.pollId = 'syncPoll_'+ count++;
this.callbacks = [];
- this.implementation = new Method({
- name: 'isSyncing',
- call: 'eth_syncing',
- params: 0,
- outputFormatter: formatters.outputSyncingFormatter
- });
-
this.addCallback(callback);
+ this.lastSyncState = false;
pollSyncing(this);
return this;
@@ -6069,40 +6167,37 @@ IsSyncing.prototype.addCallback = function (callback) {
};
IsSyncing.prototype.stopWatching = function () {
- RequestManager.getInstance().stopPolling(this.pollId);
+ this.requestManager.stopPolling(this.pollId);
this.callbacks = [];
};
module.exports = IsSyncing;
-},{"../utils/utils":20,"./formatters":29,"./method":35,"./requestmanager":43}],45:[function(require,module,exports){
+},{"../utils/utils":20,"./formatters":30}],47:[function(require,module,exports){
/*
- This file is part of ethereum.js.
+ This file is part of web3.js.
- ethereum.js is free software: you can redistribute it and/or modify
+ web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- ethereum.js is distributed in the hope that it will be useful,
+ web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
+/**
* @file transfer.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
-var web3 = require('../web3');
var Iban = require('./iban');
-var namereg = require('./namereg').ibanNamereg;
-var contract = require('./contract');
var exchangeAbi = require('../contracts/SmartExchange.json');
/**
@@ -6114,25 +6209,25 @@ var exchangeAbi = require('../contracts/SmartExchange.json');
* @param {Value} value to be tranfered
* @param {Function} callback, callback
*/
-var transfer = function (from, to, value, callback) {
- var iban = new Iban(to);
+var transfer = function (eth, from, to, value, callback) {
+ var iban = new Iban(to);
if (!iban.isValid()) {
throw new Error('invalid iban address');
}
if (iban.isDirect()) {
- return transferToAddress(from, iban.address(), value, callback);
+ return transferToAddress(eth, from, iban.address(), value, callback);
}
-
+
if (!callback) {
- var address = namereg.addr(iban.institution());
- return deposit(from, address, value, iban.client());
+ var address = eth.icapNamereg().addr(iban.institution());
+ return deposit(eth, from, address, value, iban.client());
}
- namereg.addr(iban.institution(), function (err, address) {
- return deposit(from, address, value, iban.client(), callback);
+ eth.icapNamereg().addr(iban.institution(), function (err, address) {
+ return deposit(eth, from, address, value, iban.client(), callback);
});
-
+
};
/**
@@ -6144,8 +6239,8 @@ var transfer = function (from, to, value, callback) {
* @param {Value} value to be tranfered
* @param {Function} callback, callback
*/
-var transferToAddress = function (from, to, value, callback) {
- return web3.eth.sendTransaction({
+var transferToAddress = function (eth, from, to, value, callback) {
+ return eth.sendTransaction({
address: to,
from: from,
value: value
@@ -6162,9 +6257,9 @@ var transferToAddress = function (from, to, value, callback) {
* @param {String} client unique identifier
* @param {Function} callback, callback
*/
-var deposit = function (from, to, value, client, callback) {
+var deposit = function (eth, from, to, value, client, callback) {
var abi = exchangeAbi;
- return contract(abi).at(to).deposit(client, {
+ return eth.contract(abi).at(to).deposit(client, {
from: from,
value: value
}, callback);
@@ -6173,9 +6268,1113 @@ var deposit = function (from, to, value, client, callback) {
module.exports = transfer;
-},{"../contracts/SmartExchange.json":3,"../web3":22,"./contract":25,"./iban":32,"./namereg":41}],46:[function(require,module,exports){
+},{"../contracts/SmartExchange.json":3,"./iban":33}],48:[function(require,module,exports){
+
+},{}],49:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var BlockCipher = C_lib.BlockCipher;
+ var C_algo = C.algo;
+
+ // Lookup tables
+ var SBOX = [];
+ var INV_SBOX = [];
+ var SUB_MIX_0 = [];
+ var SUB_MIX_1 = [];
+ var SUB_MIX_2 = [];
+ var SUB_MIX_3 = [];
+ var INV_SUB_MIX_0 = [];
+ var INV_SUB_MIX_1 = [];
+ var INV_SUB_MIX_2 = [];
+ var INV_SUB_MIX_3 = [];
+
+ // Compute lookup tables
+ (function () {
+ // Compute double table
+ var d = [];
+ for (var i = 0; i < 256; i++) {
+ if (i < 128) {
+ d[i] = i << 1;
+ } else {
+ d[i] = (i << 1) ^ 0x11b;
+ }
+ }
+
+ // Walk GF(2^8)
+ var x = 0;
+ var xi = 0;
+ for (var i = 0; i < 256; i++) {
+ // Compute sbox
+ var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
+ sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
+ SBOX[x] = sx;
+ INV_SBOX[sx] = x;
+
+ // Compute multiplication
+ var x2 = d[x];
+ var x4 = d[x2];
+ var x8 = d[x4];
+
+ // Compute sub bytes, mix columns tables
+ var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
+ SUB_MIX_0[x] = (t << 24) | (t >>> 8);
+ SUB_MIX_1[x] = (t << 16) | (t >>> 16);
+ SUB_MIX_2[x] = (t << 8) | (t >>> 24);
+ SUB_MIX_3[x] = t;
+
+ // Compute inv sub bytes, inv mix columns tables
+ var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
+ INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
+ INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
+ INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
+ INV_SUB_MIX_3[sx] = t;
+
+ // Compute next counter
+ if (!x) {
+ x = xi = 1;
+ } else {
+ x = x2 ^ d[d[d[x8 ^ x2]]];
+ xi ^= d[d[xi]];
+ }
+ }
+ }());
+
+ // Precomputed Rcon lookup
+ var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
+
+ /**
+ * AES block cipher algorithm.
+ */
+ var AES = C_algo.AES = BlockCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var key = this._key;
+ var keyWords = key.words;
+ var keySize = key.sigBytes / 4;
+
+ // Compute number of rounds
+ var nRounds = this._nRounds = keySize + 6
+
+ // Compute number of key schedule rows
+ var ksRows = (nRounds + 1) * 4;
+
+ // Compute key schedule
+ var keySchedule = this._keySchedule = [];
+ for (var ksRow = 0; ksRow < ksRows; ksRow++) {
+ if (ksRow < keySize) {
+ keySchedule[ksRow] = keyWords[ksRow];
+ } else {
+ var t = keySchedule[ksRow - 1];
+
+ if (!(ksRow % keySize)) {
+ // Rot word
+ t = (t << 8) | (t >>> 24);
+
+ // Sub word
+ t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
+
+ // Mix Rcon
+ t ^= RCON[(ksRow / keySize) | 0] << 24;
+ } else if (keySize > 6 && ksRow % keySize == 4) {
+ // Sub word
+ t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
+ }
+
+ keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
+ }
+ }
+
+ // Compute inv key schedule
+ var invKeySchedule = this._invKeySchedule = [];
+ for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
+ var ksRow = ksRows - invKsRow;
+
+ if (invKsRow % 4) {
+ var t = keySchedule[ksRow];
+ } else {
+ var t = keySchedule[ksRow - 4];
+ }
+
+ if (invKsRow < 4 || ksRow <= 4) {
+ invKeySchedule[invKsRow] = t;
+ } else {
+ invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
+ INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
+ }
+ }
+ },
+
+ encryptBlock: function (M, offset) {
+ this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
+ },
+
+ decryptBlock: function (M, offset) {
+ // Swap 2nd and 4th rows
+ var t = M[offset + 1];
+ M[offset + 1] = M[offset + 3];
+ M[offset + 3] = t;
+
+ this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
+
+ // Inv swap 2nd and 4th rows
+ var t = M[offset + 1];
+ M[offset + 1] = M[offset + 3];
+ M[offset + 3] = t;
+ },
+
+ _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
+ // Shortcut
+ var nRounds = this._nRounds;
+
+ // Get input, add round key
+ var s0 = M[offset] ^ keySchedule[0];
+ var s1 = M[offset + 1] ^ keySchedule[1];
+ var s2 = M[offset + 2] ^ keySchedule[2];
+ var s3 = M[offset + 3] ^ keySchedule[3];
+
+ // Key schedule row counter
+ var ksRow = 4;
+
+ // Rounds
+ for (var round = 1; round < nRounds; round++) {
+ // Shift rows, sub bytes, mix columns, add round key
+ 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++];
+ 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++];
+ 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++];
+ 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++];
+
+ // Update state
+ s0 = t0;
+ s1 = t1;
+ s2 = t2;
+ s3 = t3;
+ }
+
+ // Shift rows, sub bytes, add round key
+ var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
+ var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
+ var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
+ var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
+
+ // Set output
+ M[offset] = t0;
+ M[offset + 1] = t1;
+ M[offset + 2] = t2;
+ M[offset + 3] = t3;
+ },
+
+ keySize: 256/32
+ });
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
+ */
+ C.AES = BlockCipher._createHelper(AES);
+ }());
+
+
+ return CryptoJS.AES;
-},{}],47:[function(require,module,exports){
+}));
+},{"./cipher-core":50,"./core":51,"./enc-base64":52,"./evpkdf":54,"./md5":59}],50:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * Cipher core components.
+ */
+ CryptoJS.lib.Cipher || (function (undefined) {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var Base = C_lib.Base;
+ var WordArray = C_lib.WordArray;
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
+ var C_enc = C.enc;
+ var Utf8 = C_enc.Utf8;
+ var Base64 = C_enc.Base64;
+ var C_algo = C.algo;
+ var EvpKDF = C_algo.EvpKDF;
+
+ /**
+ * Abstract base cipher template.
+ *
+ * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
+ * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
+ * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
+ * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
+ */
+ var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {WordArray} iv The IV to use for this operation.
+ */
+ cfg: Base.extend(),
+
+ /**
+ * Creates this cipher in encryption mode.
+ *
+ * @param {WordArray} key The key.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @return {Cipher} A cipher instance.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
+ */
+ createEncryptor: function (key, cfg) {
+ return this.create(this._ENC_XFORM_MODE, key, cfg);
+ },
+
+ /**
+ * Creates this cipher in decryption mode.
+ *
+ * @param {WordArray} key The key.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @return {Cipher} A cipher instance.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
+ */
+ createDecryptor: function (key, cfg) {
+ return this.create(this._DEC_XFORM_MODE, key, cfg);
+ },
+
+ /**
+ * Initializes a newly created cipher.
+ *
+ * @param {number} xformMode Either the encryption or decryption transormation mode constant.
+ * @param {WordArray} key The key.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @example
+ *
+ * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
+ */
+ init: function (xformMode, key, cfg) {
+ // Apply config defaults
+ this.cfg = this.cfg.extend(cfg);
+
+ // Store transform mode and key
+ this._xformMode = xformMode;
+ this._key = key;
+
+ // Set initial values
+ this.reset();
+ },
+
+ /**
+ * Resets this cipher to its initial state.
+ *
+ * @example
+ *
+ * cipher.reset();
+ */
+ reset: function () {
+ // Reset data buffer
+ BufferedBlockAlgorithm.reset.call(this);
+
+ // Perform concrete-cipher logic
+ this._doReset();
+ },
+
+ /**
+ * Adds data to be encrypted or decrypted.
+ *
+ * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
+ *
+ * @return {WordArray} The data after processing.
+ *
+ * @example
+ *
+ * var encrypted = cipher.process('data');
+ * var encrypted = cipher.process(wordArray);
+ */
+ process: function (dataUpdate) {
+ // Append
+ this._append(dataUpdate);
+
+ // Process available blocks
+ return this._process();
+ },
+
+ /**
+ * Finalizes the encryption or decryption process.
+ * Note that the finalize operation is effectively a destructive, read-once operation.
+ *
+ * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
+ *
+ * @return {WordArray} The data after final processing.
+ *
+ * @example
+ *
+ * var encrypted = cipher.finalize();
+ * var encrypted = cipher.finalize('data');
+ * var encrypted = cipher.finalize(wordArray);
+ */
+ finalize: function (dataUpdate) {
+ // Final data update
+ if (dataUpdate) {
+ this._append(dataUpdate);
+ }
+
+ // Perform concrete-cipher logic
+ var finalProcessedData = this._doFinalize();
+
+ return finalProcessedData;
+ },
+
+ keySize: 128/32,
+
+ ivSize: 128/32,
+
+ _ENC_XFORM_MODE: 1,
+
+ _DEC_XFORM_MODE: 2,
+
+ /**
+ * Creates shortcut functions to a cipher's object interface.
+ *
+ * @param {Cipher} cipher The cipher to create a helper for.
+ *
+ * @return {Object} An object with encrypt and decrypt shortcut functions.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
+ */
+ _createHelper: (function () {
+ function selectCipherStrategy(key) {
+ if (typeof key == 'string') {
+ return PasswordBasedCipher;
+ } else {
+ return SerializableCipher;
+ }
+ }
+
+ return function (cipher) {
+ return {
+ encrypt: function (message, key, cfg) {
+ return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
+ },
+
+ decrypt: function (ciphertext, key, cfg) {
+ return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
+ }
+ };
+ };
+ }())
+ });
+
+ /**
+ * Abstract base stream cipher template.
+ *
+ * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
+ */
+ var StreamCipher = C_lib.StreamCipher = Cipher.extend({
+ _doFinalize: function () {
+ // Process partial blocks
+ var finalProcessedBlocks = this._process(!!'flush');
+
+ return finalProcessedBlocks;
+ },
+
+ blockSize: 1
+ });
+
+ /**
+ * Mode namespace.
+ */
+ var C_mode = C.mode = {};
+
+ /**
+ * Abstract base block cipher mode template.
+ */
+ var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
+ /**
+ * Creates this mode for encryption.
+ *
+ * @param {Cipher} cipher A block cipher instance.
+ * @param {Array} iv The IV words.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
+ */
+ createEncryptor: function (cipher, iv) {
+ return this.Encryptor.create(cipher, iv);
+ },
+
+ /**
+ * Creates this mode for decryption.
+ *
+ * @param {Cipher} cipher A block cipher instance.
+ * @param {Array} iv The IV words.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
+ */
+ createDecryptor: function (cipher, iv) {
+ return this.Decryptor.create(cipher, iv);
+ },
+
+ /**
+ * Initializes a newly created mode.
+ *
+ * @param {Cipher} cipher A block cipher instance.
+ * @param {Array} iv The IV words.
+ *
+ * @example
+ *
+ * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
+ */
+ init: function (cipher, iv) {
+ this._cipher = cipher;
+ this._iv = iv;
+ }
+ });
+
+ /**
+ * Cipher Block Chaining mode.
+ */
+ var CBC = C_mode.CBC = (function () {
+ /**
+ * Abstract base CBC mode.
+ */
+ var CBC = BlockCipherMode.extend();
+
+ /**
+ * CBC encryptor.
+ */
+ CBC.Encryptor = CBC.extend({
+ /**
+ * Processes the data block at offset.
+ *
+ * @param {Array} words The data words to operate on.
+ * @param {number} offset The offset where the block starts.
+ *
+ * @example
+ *
+ * mode.processBlock(data.words, offset);
+ */
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher;
+ var blockSize = cipher.blockSize;
+
+ // XOR and encrypt
+ xorBlock.call(this, words, offset, blockSize);
+ cipher.encryptBlock(words, offset);
+
+ // Remember this block to use with next block
+ this._prevBlock = words.slice(offset, offset + blockSize);
+ }
+ });
+
+ /**
+ * CBC decryptor.
+ */
+ CBC.Decryptor = CBC.extend({
+ /**
+ * Processes the data block at offset.
+ *
+ * @param {Array} words The data words to operate on.
+ * @param {number} offset The offset where the block starts.
+ *
+ * @example
+ *
+ * mode.processBlock(data.words, offset);
+ */
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher;
+ var blockSize = cipher.blockSize;
+
+ // Remember this block to use with next block
+ var thisBlock = words.slice(offset, offset + blockSize);
+
+ // Decrypt and XOR
+ cipher.decryptBlock(words, offset);
+ xorBlock.call(this, words, offset, blockSize);
+
+ // This block becomes the previous block
+ this._prevBlock = thisBlock;
+ }
+ });
+
+ function xorBlock(words, offset, blockSize) {
+ // Shortcut
+ var iv = this._iv;
+
+ // Choose mixing block
+ if (iv) {
+ var block = iv;
+
+ // Remove IV for subsequent blocks
+ this._iv = undefined;
+ } else {
+ var block = this._prevBlock;
+ }
+
+ // XOR blocks
+ for (var i = 0; i < blockSize; i++) {
+ words[offset + i] ^= block[i];
+ }
+ }
+
+ return CBC;
+ }());
+
+ /**
+ * Padding namespace.
+ */
+ var C_pad = C.pad = {};
+
+ /**
+ * PKCS #5/7 padding strategy.
+ */
+ var Pkcs7 = C_pad.Pkcs7 = {
+ /**
+ * Pads data using the algorithm defined in PKCS #5/7.
+ *
+ * @param {WordArray} data The data to pad.
+ * @param {number} blockSize The multiple that the data should be padded to.
+ *
+ * @static
+ *
+ * @example
+ *
+ * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
+ */
+ pad: function (data, blockSize) {
+ // Shortcut
+ var blockSizeBytes = blockSize * 4;
+
+ // Count padding bytes
+ var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
+
+ // Create padding word
+ var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
+
+ // Create padding
+ var paddingWords = [];
+ for (var i = 0; i < nPaddingBytes; i += 4) {
+ paddingWords.push(paddingWord);
+ }
+ var padding = WordArray.create(paddingWords, nPaddingBytes);
+
+ // Add padding
+ data.concat(padding);
+ },
+
+ /**
+ * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
+ *
+ * @param {WordArray} data The data to unpad.
+ *
+ * @static
+ *
+ * @example
+ *
+ * CryptoJS.pad.Pkcs7.unpad(wordArray);
+ */
+ unpad: function (data) {
+ // Get number of padding bytes from last byte
+ var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
+
+ // Remove padding
+ data.sigBytes -= nPaddingBytes;
+ }
+ };
+
+ /**
+ * Abstract base block cipher template.
+ *
+ * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
+ */
+ var BlockCipher = C_lib.BlockCipher = Cipher.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {Mode} mode The block mode to use. Default: CBC
+ * @property {Padding} padding The padding strategy to use. Default: Pkcs7
+ */
+ cfg: Cipher.cfg.extend({
+ mode: CBC,
+ padding: Pkcs7
+ }),
+
+ reset: function () {
+ // Reset cipher
+ Cipher.reset.call(this);
+
+ // Shortcuts
+ var cfg = this.cfg;
+ var iv = cfg.iv;
+ var mode = cfg.mode;
+
+ // Reset block mode
+ if (this._xformMode == this._ENC_XFORM_MODE) {
+ var modeCreator = mode.createEncryptor;
+ } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
+ var modeCreator = mode.createDecryptor;
+
+ // Keep at least one block in the buffer for unpadding
+ this._minBufferSize = 1;
+ }
+ this._mode = modeCreator.call(mode, this, iv && iv.words);
+ },
+
+ _doProcessBlock: function (words, offset) {
+ this._mode.processBlock(words, offset);
+ },
+
+ _doFinalize: function () {
+ // Shortcut
+ var padding = this.cfg.padding;
+
+ // Finalize
+ if (this._xformMode == this._ENC_XFORM_MODE) {
+ // Pad data
+ padding.pad(this._data, this.blockSize);
+
+ // Process final blocks
+ var finalProcessedBlocks = this._process(!!'flush');
+ } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
+ // Process final blocks
+ var finalProcessedBlocks = this._process(!!'flush');
+
+ // Unpad data
+ padding.unpad(finalProcessedBlocks);
+ }
+
+ return finalProcessedBlocks;
+ },
+
+ blockSize: 128/32
+ });
+
+ /**
+ * A collection of cipher parameters.
+ *
+ * @property {WordArray} ciphertext The raw ciphertext.
+ * @property {WordArray} key The key to this ciphertext.
+ * @property {WordArray} iv The IV used in the ciphering operation.
+ * @property {WordArray} salt The salt used with a key derivation function.
+ * @property {Cipher} algorithm The cipher algorithm.
+ * @property {Mode} mode The block mode used in the ciphering operation.
+ * @property {Padding} padding The padding scheme used in the ciphering operation.
+ * @property {number} blockSize The block size of the cipher.
+ * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
+ */
+ var CipherParams = C_lib.CipherParams = Base.extend({
+ /**
+ * Initializes a newly created cipher params object.
+ *
+ * @param {Object} cipherParams An object with any of the possible cipher parameters.
+ *
+ * @example
+ *
+ * var cipherParams = CryptoJS.lib.CipherParams.create({
+ * ciphertext: ciphertextWordArray,
+ * key: keyWordArray,
+ * iv: ivWordArray,
+ * salt: saltWordArray,
+ * algorithm: CryptoJS.algo.AES,
+ * mode: CryptoJS.mode.CBC,
+ * padding: CryptoJS.pad.PKCS7,
+ * blockSize: 4,
+ * formatter: CryptoJS.format.OpenSSL
+ * });
+ */
+ init: function (cipherParams) {
+ this.mixIn(cipherParams);
+ },
+
+ /**
+ * Converts this cipher params object to a string.
+ *
+ * @param {Format} formatter (Optional) The formatting strategy to use.
+ *
+ * @return {string} The stringified cipher params.
+ *
+ * @throws Error If neither the formatter nor the default formatter is set.
+ *
+ * @example
+ *
+ * var string = cipherParams + '';
+ * var string = cipherParams.toString();
+ * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
+ */
+ toString: function (formatter) {
+ return (formatter || this.formatter).stringify(this);
+ }
+ });
+
+ /**
+ * Format namespace.
+ */
+ var C_format = C.format = {};
+
+ /**
+ * OpenSSL formatting strategy.
+ */
+ var OpenSSLFormatter = C_format.OpenSSL = {
+ /**
+ * Converts a cipher params object to an OpenSSL-compatible string.
+ *
+ * @param {CipherParams} cipherParams The cipher params object.
+ *
+ * @return {string} The OpenSSL-compatible string.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
+ */
+ stringify: function (cipherParams) {
+ // Shortcuts
+ var ciphertext = cipherParams.ciphertext;
+ var salt = cipherParams.salt;
+
+ // Format
+ if (salt) {
+ var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
+ } else {
+ var wordArray = ciphertext;
+ }
+
+ return wordArray.toString(Base64);
+ },
+
+ /**
+ * Converts an OpenSSL-compatible string to a cipher params object.
+ *
+ * @param {string} openSSLStr The OpenSSL-compatible string.
+ *
+ * @return {CipherParams} The cipher params object.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
+ */
+ parse: function (openSSLStr) {
+ // Parse base64
+ var ciphertext = Base64.parse(openSSLStr);
+
+ // Shortcut
+ var ciphertextWords = ciphertext.words;
+
+ // Test for salt
+ if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
+ // Extract salt
+ var salt = WordArray.create(ciphertextWords.slice(2, 4));
+
+ // Remove salt from ciphertext
+ ciphertextWords.splice(0, 4);
+ ciphertext.sigBytes -= 16;
+ }
+
+ return CipherParams.create({ ciphertext: ciphertext, salt: salt });
+ }
+ };
+
+ /**
+ * A cipher wrapper that returns ciphertext as a serializable cipher params object.
+ */
+ var SerializableCipher = C_lib.SerializableCipher = Base.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
+ */
+ cfg: Base.extend({
+ format: OpenSSLFormatter
+ }),
+
+ /**
+ * Encrypts a message.
+ *
+ * @param {Cipher} cipher The cipher algorithm to use.
+ * @param {WordArray|string} message The message to encrypt.
+ * @param {WordArray} key The key.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @return {CipherParams} A cipher params object.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
+ * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
+ * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
+ */
+ encrypt: function (cipher, message, key, cfg) {
+ // Apply config defaults
+ cfg = this.cfg.extend(cfg);
+
+ // Encrypt
+ var encryptor = cipher.createEncryptor(key, cfg);
+ var ciphertext = encryptor.finalize(message);
+
+ // Shortcut
+ var cipherCfg = encryptor.cfg;
+
+ // Create and return serializable cipher params
+ return CipherParams.create({
+ ciphertext: ciphertext,
+ key: key,
+ iv: cipherCfg.iv,
+ algorithm: cipher,
+ mode: cipherCfg.mode,
+ padding: cipherCfg.padding,
+ blockSize: cipher.blockSize,
+ formatter: cfg.format
+ });
+ },
+
+ /**
+ * Decrypts serialized ciphertext.
+ *
+ * @param {Cipher} cipher The cipher algorithm to use.
+ * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
+ * @param {WordArray} key The key.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @return {WordArray} The plaintext.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
+ * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
+ */
+ decrypt: function (cipher, ciphertext, key, cfg) {
+ // Apply config defaults
+ cfg = this.cfg.extend(cfg);
+
+ // Convert string to CipherParams
+ ciphertext = this._parse(ciphertext, cfg.format);
+
+ // Decrypt
+ var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
+
+ return plaintext;
+ },
+
+ /**
+ * Converts serialized ciphertext to CipherParams,
+ * else assumed CipherParams already and returns ciphertext unchanged.
+ *
+ * @param {CipherParams|string} ciphertext The ciphertext.
+ * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
+ *
+ * @return {CipherParams} The unserialized ciphertext.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
+ */
+ _parse: function (ciphertext, format) {
+ if (typeof ciphertext == 'string') {
+ return format.parse(ciphertext, this);
+ } else {
+ return ciphertext;
+ }
+ }
+ });
+
+ /**
+ * Key derivation function namespace.
+ */
+ var C_kdf = C.kdf = {};
+
+ /**
+ * OpenSSL key derivation function.
+ */
+ var OpenSSLKdf = C_kdf.OpenSSL = {
+ /**
+ * Derives a key and IV from a password.
+ *
+ * @param {string} password The password to derive from.
+ * @param {number} keySize The size in words of the key to generate.
+ * @param {number} ivSize The size in words of the IV to generate.
+ * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
+ *
+ * @return {CipherParams} A cipher params object with the key, IV, and salt.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
+ * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
+ */
+ execute: function (password, keySize, ivSize, salt) {
+ // Generate random salt
+ if (!salt) {
+ salt = WordArray.random(64/8);
+ }
+
+ // Derive key and IV
+ var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
+
+ // Separate key and IV
+ var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
+ key.sigBytes = keySize * 4;
+
+ // Return params
+ return CipherParams.create({ key: key, iv: iv, salt: salt });
+ }
+ };
+
+ /**
+ * A serializable cipher wrapper that derives the key from a password,
+ * and returns ciphertext as a serializable cipher params object.
+ */
+ var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
+ */
+ cfg: SerializableCipher.cfg.extend({
+ kdf: OpenSSLKdf
+ }),
+
+ /**
+ * Encrypts a message using a password.
+ *
+ * @param {Cipher} cipher The cipher algorithm to use.
+ * @param {WordArray|string} message The message to encrypt.
+ * @param {string} password The password.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @return {CipherParams} A cipher params object.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
+ * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
+ */
+ encrypt: function (cipher, message, password, cfg) {
+ // Apply config defaults
+ cfg = this.cfg.extend(cfg);
+
+ // Derive key and other params
+ var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
+
+ // Add IV to config
+ cfg.iv = derivedParams.iv;
+
+ // Encrypt
+ var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
+
+ // Mix in derived params
+ ciphertext.mixIn(derivedParams);
+
+ return ciphertext;
+ },
+
+ /**
+ * Decrypts serialized ciphertext using a password.
+ *
+ * @param {Cipher} cipher The cipher algorithm to use.
+ * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
+ * @param {string} password The password.
+ * @param {Object} cfg (Optional) The configuration options to use for this operation.
+ *
+ * @return {WordArray} The plaintext.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
+ * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
+ */
+ decrypt: function (cipher, ciphertext, password, cfg) {
+ // Apply config defaults
+ cfg = this.cfg.extend(cfg);
+
+ // Convert string to CipherParams
+ ciphertext = this._parse(ciphertext, cfg.format);
+
+ // Derive key and other params
+ var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
+
+ // Add IV to config
+ cfg.iv = derivedParams.iv;
+
+ // Decrypt
+ var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
+
+ return plaintext;
+ }
+ });
+ }());
+
+
+}));
+},{"./core":51}],51:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@@ -6918,7 +8117,2924 @@ module.exports = transfer;
return CryptoJS;
}));
-},{}],48:[function(require,module,exports){
+},{}],52:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var C_enc = C.enc;
+
+ /**
+ * Base64 encoding strategy.
+ */
+ var Base64 = C_enc.Base64 = {
+ /**
+ * Converts a word array to a Base64 string.
+ *
+ * @param {WordArray} wordArray The word array.
+ *
+ * @return {string} The Base64 string.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
+ */
+ stringify: function (wordArray) {
+ // Shortcuts
+ var words = wordArray.words;
+ var sigBytes = wordArray.sigBytes;
+ var map = this._map;
+
+ // Clamp excess bits
+ wordArray.clamp();
+
+ // Convert
+ var base64Chars = [];
+ for (var i = 0; i < sigBytes; i += 3) {
+ var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
+ var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
+ var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
+
+ var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
+
+ for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
+ base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
+ }
+ }
+
+ // Add padding
+ var paddingChar = map.charAt(64);
+ if (paddingChar) {
+ while (base64Chars.length % 4) {
+ base64Chars.push(paddingChar);
+ }
+ }
+
+ return base64Chars.join('');
+ },
+
+ /**
+ * Converts a Base64 string to a word array.
+ *
+ * @param {string} base64Str The Base64 string.
+ *
+ * @return {WordArray} The word array.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var wordArray = CryptoJS.enc.Base64.parse(base64String);
+ */
+ parse: function (base64Str) {
+ // Shortcuts
+ var base64StrLength = base64Str.length;
+ var map = this._map;
+
+ // Ignore padding
+ var paddingChar = map.charAt(64);
+ if (paddingChar) {
+ var paddingIndex = base64Str.indexOf(paddingChar);
+ if (paddingIndex != -1) {
+ base64StrLength = paddingIndex;
+ }
+ }
+
+ // Convert
+ var words = [];
+ var nBytes = 0;
+ for (var i = 0; i < base64StrLength; i++) {
+ if (i % 4) {
+ var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
+ var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
+ words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
+ nBytes++;
+ }
+ }
+
+ return WordArray.create(words, nBytes);
+ },
+
+ _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
+ };
+ }());
+
+
+ return CryptoJS.enc.Base64;
+
+}));
+},{"./core":51}],53:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var C_enc = C.enc;
+
+ /**
+ * UTF-16 BE encoding strategy.
+ */
+ var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
+ /**
+ * Converts a word array to a UTF-16 BE string.
+ *
+ * @param {WordArray} wordArray The word array.
+ *
+ * @return {string} The UTF-16 BE string.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
+ */
+ stringify: function (wordArray) {
+ // Shortcuts
+ var words = wordArray.words;
+ var sigBytes = wordArray.sigBytes;
+
+ // Convert
+ var utf16Chars = [];
+ for (var i = 0; i < sigBytes; i += 2) {
+ var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
+ utf16Chars.push(String.fromCharCode(codePoint));
+ }
+
+ return utf16Chars.join('');
+ },
+
+ /**
+ * Converts a UTF-16 BE string to a word array.
+ *
+ * @param {string} utf16Str The UTF-16 BE string.
+ *
+ * @return {WordArray} The word array.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
+ */
+ parse: function (utf16Str) {
+ // Shortcut
+ var utf16StrLength = utf16Str.length;
+
+ // Convert
+ var words = [];
+ for (var i = 0; i < utf16StrLength; i++) {
+ words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
+ }
+
+ return WordArray.create(words, utf16StrLength * 2);
+ }
+ };
+
+ /**
+ * UTF-16 LE encoding strategy.
+ */
+ C_enc.Utf16LE = {
+ /**
+ * Converts a word array to a UTF-16 LE string.
+ *
+ * @param {WordArray} wordArray The word array.
+ *
+ * @return {string} The UTF-16 LE string.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
+ */
+ stringify: function (wordArray) {
+ // Shortcuts
+ var words = wordArray.words;
+ var sigBytes = wordArray.sigBytes;
+
+ // Convert
+ var utf16Chars = [];
+ for (var i = 0; i < sigBytes; i += 2) {
+ var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
+ utf16Chars.push(String.fromCharCode(codePoint));
+ }
+
+ return utf16Chars.join('');
+ },
+
+ /**
+ * Converts a UTF-16 LE string to a word array.
+ *
+ * @param {string} utf16Str The UTF-16 LE string.
+ *
+ * @return {WordArray} The word array.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
+ */
+ parse: function (utf16Str) {
+ // Shortcut
+ var utf16StrLength = utf16Str.length;
+
+ // Convert
+ var words = [];
+ for (var i = 0; i < utf16StrLength; i++) {
+ words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
+ }
+
+ return WordArray.create(words, utf16StrLength * 2);
+ }
+ };
+
+ function swapEndian(word) {
+ return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
+ }
+ }());
+
+
+ return CryptoJS.enc.Utf16;
+
+}));
+},{"./core":51}],54:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./sha1", "./hmac"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var Base = C_lib.Base;
+ var WordArray = C_lib.WordArray;
+ var C_algo = C.algo;
+ var MD5 = C_algo.MD5;
+
+ /**
+ * This key derivation function is meant to conform with EVP_BytesToKey.
+ * www.openssl.org/docs/crypto/EVP_BytesToKey.html
+ */
+ var EvpKDF = C_algo.EvpKDF = Base.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
+ * @property {Hasher} hasher The hash algorithm to use. Default: MD5
+ * @property {number} iterations The number of iterations to perform. Default: 1
+ */
+ cfg: Base.extend({
+ keySize: 128/32,
+ hasher: MD5,
+ iterations: 1
+ }),
+
+ /**
+ * Initializes a newly created key derivation function.
+ *
+ * @param {Object} cfg (Optional) The configuration options to use for the derivation.
+ *
+ * @example
+ *
+ * var kdf = CryptoJS.algo.EvpKDF.create();
+ * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
+ * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
+ */
+ init: function (cfg) {
+ this.cfg = this.cfg.extend(cfg);
+ },
+
+ /**
+ * Derives a key from a password.
+ *
+ * @param {WordArray|string} password The password.
+ * @param {WordArray|string} salt A salt.
+ *
+ * @return {WordArray} The derived key.
+ *
+ * @example
+ *
+ * var key = kdf.compute(password, salt);
+ */
+ compute: function (password, salt) {
+ // Shortcut
+ var cfg = this.cfg;
+
+ // Init hasher
+ var hasher = cfg.hasher.create();
+
+ // Initial values
+ var derivedKey = WordArray.create();
+
+ // Shortcuts
+ var derivedKeyWords = derivedKey.words;
+ var keySize = cfg.keySize;
+ var iterations = cfg.iterations;
+
+ // Generate key
+ while (derivedKeyWords.length < keySize) {
+ if (block) {
+ hasher.update(block);
+ }
+ var block = hasher.update(password).finalize(salt);
+ hasher.reset();
+
+ // Iterations
+ for (var i = 1; i < iterations; i++) {
+ block = hasher.finalize(block);
+ hasher.reset();
+ }
+
+ derivedKey.concat(block);
+ }
+ derivedKey.sigBytes = keySize * 4;
+
+ return derivedKey;
+ }
+ });
+
+ /**
+ * Derives a key from a password.
+ *
+ * @param {WordArray|string} password The password.
+ * @param {WordArray|string} salt A salt.
+ * @param {Object} cfg (Optional) The configuration options to use for this computation.
+ *
+ * @return {WordArray} The derived key.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var key = CryptoJS.EvpKDF(password, salt);
+ * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
+ * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
+ */
+ C.EvpKDF = function (password, salt, cfg) {
+ return EvpKDF.create(cfg).compute(password, salt);
+ };
+ }());
+
+
+ return CryptoJS.EvpKDF;
+
+}));
+},{"./core":51,"./hmac":56,"./sha1":75}],55:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function (undefined) {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var CipherParams = C_lib.CipherParams;
+ var C_enc = C.enc;
+ var Hex = C_enc.Hex;
+ var C_format = C.format;
+
+ var HexFormatter = C_format.Hex = {
+ /**
+ * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
+ *
+ * @param {CipherParams} cipherParams The cipher params object.
+ *
+ * @return {string} The hexadecimally encoded string.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
+ */
+ stringify: function (cipherParams) {
+ return cipherParams.ciphertext.toString(Hex);
+ },
+
+ /**
+ * Converts a hexadecimally encoded ciphertext string to a cipher params object.
+ *
+ * @param {string} input The hexadecimally encoded string.
+ *
+ * @return {CipherParams} The cipher params object.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var cipherParams = CryptoJS.format.Hex.parse(hexString);
+ */
+ parse: function (input) {
+ var ciphertext = Hex.parse(input);
+ return CipherParams.create({ ciphertext: ciphertext });
+ }
+ };
+ }());
+
+
+ return CryptoJS.format.Hex;
+
+}));
+},{"./cipher-core":50,"./core":51}],56:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var Base = C_lib.Base;
+ var C_enc = C.enc;
+ var Utf8 = C_enc.Utf8;
+ var C_algo = C.algo;
+
+ /**
+ * HMAC algorithm.
+ */
+ var HMAC = C_algo.HMAC = Base.extend({
+ /**
+ * Initializes a newly created HMAC.
+ *
+ * @param {Hasher} hasher The hash algorithm to use.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @example
+ *
+ * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
+ */
+ init: function (hasher, key) {
+ // Init hasher
+ hasher = this._hasher = new hasher.init();
+
+ // Convert string to WordArray, else assume WordArray already
+ if (typeof key == 'string') {
+ key = Utf8.parse(key);
+ }
+
+ // Shortcuts
+ var hasherBlockSize = hasher.blockSize;
+ var hasherBlockSizeBytes = hasherBlockSize * 4;
+
+ // Allow arbitrary length keys
+ if (key.sigBytes > hasherBlockSizeBytes) {
+ key = hasher.finalize(key);
+ }
+
+ // Clamp excess bits
+ key.clamp();
+
+ // Clone key for inner and outer pads
+ var oKey = this._oKey = key.clone();
+ var iKey = this._iKey = key.clone();
+
+ // Shortcuts
+ var oKeyWords = oKey.words;
+ var iKeyWords = iKey.words;
+
+ // XOR keys with pad constants
+ for (var i = 0; i < hasherBlockSize; i++) {
+ oKeyWords[i] ^= 0x5c5c5c5c;
+ iKeyWords[i] ^= 0x36363636;
+ }
+ oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
+
+ // Set initial values
+ this.reset();
+ },
+
+ /**
+ * Resets this HMAC to its initial state.
+ *
+ * @example
+ *
+ * hmacHasher.reset();
+ */
+ reset: function () {
+ // Shortcut
+ var hasher = this._hasher;
+
+ // Reset
+ hasher.reset();
+ hasher.update(this._iKey);
+ },
+
+ /**
+ * Updates this HMAC with a message.
+ *
+ * @param {WordArray|string} messageUpdate The message to append.
+ *
+ * @return {HMAC} This HMAC instance.
+ *
+ * @example
+ *
+ * hmacHasher.update('message');
+ * hmacHasher.update(wordArray);
+ */
+ update: function (messageUpdate) {
+ this._hasher.update(messageUpdate);
+
+ // Chainable
+ return this;
+ },
+
+ /**
+ * Finalizes the HMAC computation.
+ * Note that the finalize operation is effectively a destructive, read-once operation.
+ *
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @example
+ *
+ * var hmac = hmacHasher.finalize();
+ * var hmac = hmacHasher.finalize('message');
+ * var hmac = hmacHasher.finalize(wordArray);
+ */
+ finalize: function (messageUpdate) {
+ // Shortcut
+ var hasher = this._hasher;
+
+ // Compute HMAC
+ var innerHash = hasher.finalize(messageUpdate);
+ hasher.reset();
+ var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
+
+ return hmac;
+ }
+ });
+ }());
+
+
+}));
+},{"./core":51}],57:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ 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"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ 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);
+ }
+ else {
+ // Global (browser)
+ root.CryptoJS = factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ return CryptoJS;
+
+}));
+},{"./aes":49,"./cipher-core":50,"./core":51,"./enc-base64":52,"./enc-utf16":53,"./evpkdf":54,"./format-hex":55,"./hmac":56,"./lib-typedarrays":58,"./md5":59,"./mode-cfb":60,"./mode-ctr":62,"./mode-ctr-gladman":61,"./mode-ecb":63,"./mode-ofb":64,"./pad-ansix923":65,"./pad-iso10126":66,"./pad-iso97971":67,"./pad-nopadding":68,"./pad-zeropadding":69,"./pbkdf2":70,"./rabbit":72,"./rabbit-legacy":71,"./rc4":73,"./ripemd160":74,"./sha1":75,"./sha224":76,"./sha256":77,"./sha3":78,"./sha384":79,"./sha512":80,"./tripledes":81,"./x64-core":82}],58:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Check if typed arrays are supported
+ if (typeof ArrayBuffer != 'function') {
+ return;
+ }
+
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+
+ // Reference original init
+ var superInit = WordArray.init;
+
+ // Augment WordArray.init to handle typed arrays
+ var subInit = WordArray.init = function (typedArray) {
+ // Convert buffers to uint8
+ if (typedArray instanceof ArrayBuffer) {
+ typedArray = new Uint8Array(typedArray);
+ }
+
+ // Convert other array views to uint8
+ if (
+ typedArray instanceof Int8Array ||
+ (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
+ typedArray instanceof Int16Array ||
+ typedArray instanceof Uint16Array ||
+ typedArray instanceof Int32Array ||
+ typedArray instanceof Uint32Array ||
+ typedArray instanceof Float32Array ||
+ typedArray instanceof Float64Array
+ ) {
+ typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
+ }
+
+ // Handle Uint8Array
+ if (typedArray instanceof Uint8Array) {
+ // Shortcut
+ var typedArrayByteLength = typedArray.byteLength;
+
+ // Extract bytes
+ var words = [];
+ for (var i = 0; i < typedArrayByteLength; i++) {
+ words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
+ }
+
+ // Initialize this word array
+ superInit.call(this, words, typedArrayByteLength);
+ } else {
+ // Else call normal init
+ superInit.apply(this, arguments);
+ }
+ };
+
+ subInit.prototype = WordArray;
+ }());
+
+
+ return CryptoJS.lib.WordArray;
+
+}));
+},{"./core":51}],59:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function (Math) {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var Hasher = C_lib.Hasher;
+ var C_algo = C.algo;
+
+ // Constants table
+ var T = [];
+
+ // Compute constants
+ (function () {
+ for (var i = 0; i < 64; i++) {
+ T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
+ }
+ }());
+
+ /**
+ * MD5 hash algorithm.
+ */
+ var MD5 = C_algo.MD5 = Hasher.extend({
+ _doReset: function () {
+ this._hash = new WordArray.init([
+ 0x67452301, 0xefcdab89,
+ 0x98badcfe, 0x10325476
+ ]);
+ },
+
+ _doProcessBlock: function (M, offset) {
+ // Swap endian
+ for (var i = 0; i < 16; i++) {
+ // Shortcuts
+ var offset_i = offset + i;
+ var M_offset_i = M[offset_i];
+
+ M[offset_i] = (
+ (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
+ (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
+ );
+ }
+
+ // Shortcuts
+ var H = this._hash.words;
+
+ var M_offset_0 = M[offset + 0];
+ var M_offset_1 = M[offset + 1];
+ var M_offset_2 = M[offset + 2];
+ var M_offset_3 = M[offset + 3];
+ var M_offset_4 = M[offset + 4];
+ var M_offset_5 = M[offset + 5];
+ var M_offset_6 = M[offset + 6];
+ var M_offset_7 = M[offset + 7];
+ var M_offset_8 = M[offset + 8];
+ var M_offset_9 = M[offset + 9];
+ var M_offset_10 = M[offset + 10];
+ var M_offset_11 = M[offset + 11];
+ var M_offset_12 = M[offset + 12];
+ var M_offset_13 = M[offset + 13];
+ var M_offset_14 = M[offset + 14];
+ var M_offset_15 = M[offset + 15];
+
+ // Working varialbes
+ var a = H[0];
+ var b = H[1];
+ var c = H[2];
+ var d = H[3];
+
+ // Computation
+ a = FF(a, b, c, d, M_offset_0, 7, T[0]);
+ d = FF(d, a, b, c, M_offset_1, 12, T[1]);
+ c = FF(c, d, a, b, M_offset_2, 17, T[2]);
+ b = FF(b, c, d, a, M_offset_3, 22, T[3]);
+ a = FF(a, b, c, d, M_offset_4, 7, T[4]);
+ d = FF(d, a, b, c, M_offset_5, 12, T[5]);
+ c = FF(c, d, a, b, M_offset_6, 17, T[6]);
+ b = FF(b, c, d, a, M_offset_7, 22, T[7]);
+ a = FF(a, b, c, d, M_offset_8, 7, T[8]);
+ d = FF(d, a, b, c, M_offset_9, 12, T[9]);
+ c = FF(c, d, a, b, M_offset_10, 17, T[10]);
+ b = FF(b, c, d, a, M_offset_11, 22, T[11]);
+ a = FF(a, b, c, d, M_offset_12, 7, T[12]);
+ d = FF(d, a, b, c, M_offset_13, 12, T[13]);
+ c = FF(c, d, a, b, M_offset_14, 17, T[14]);
+ b = FF(b, c, d, a, M_offset_15, 22, T[15]);
+
+ a = GG(a, b, c, d, M_offset_1, 5, T[16]);
+ d = GG(d, a, b, c, M_offset_6, 9, T[17]);
+ c = GG(c, d, a, b, M_offset_11, 14, T[18]);
+ b = GG(b, c, d, a, M_offset_0, 20, T[19]);
+ a = GG(a, b, c, d, M_offset_5, 5, T[20]);
+ d = GG(d, a, b, c, M_offset_10, 9, T[21]);
+ c = GG(c, d, a, b, M_offset_15, 14, T[22]);
+ b = GG(b, c, d, a, M_offset_4, 20, T[23]);
+ a = GG(a, b, c, d, M_offset_9, 5, T[24]);
+ d = GG(d, a, b, c, M_offset_14, 9, T[25]);
+ c = GG(c, d, a, b, M_offset_3, 14, T[26]);
+ b = GG(b, c, d, a, M_offset_8, 20, T[27]);
+ a = GG(a, b, c, d, M_offset_13, 5, T[28]);
+ d = GG(d, a, b, c, M_offset_2, 9, T[29]);
+ c = GG(c, d, a, b, M_offset_7, 14, T[30]);
+ b = GG(b, c, d, a, M_offset_12, 20, T[31]);
+
+ a = HH(a, b, c, d, M_offset_5, 4, T[32]);
+ d = HH(d, a, b, c, M_offset_8, 11, T[33]);
+ c = HH(c, d, a, b, M_offset_11, 16, T[34]);
+ b = HH(b, c, d, a, M_offset_14, 23, T[35]);
+ a = HH(a, b, c, d, M_offset_1, 4, T[36]);
+ d = HH(d, a, b, c, M_offset_4, 11, T[37]);
+ c = HH(c, d, a, b, M_offset_7, 16, T[38]);
+ b = HH(b, c, d, a, M_offset_10, 23, T[39]);
+ a = HH(a, b, c, d, M_offset_13, 4, T[40]);
+ d = HH(d, a, b, c, M_offset_0, 11, T[41]);
+ c = HH(c, d, a, b, M_offset_3, 16, T[42]);
+ b = HH(b, c, d, a, M_offset_6, 23, T[43]);
+ a = HH(a, b, c, d, M_offset_9, 4, T[44]);
+ d = HH(d, a, b, c, M_offset_12, 11, T[45]);
+ c = HH(c, d, a, b, M_offset_15, 16, T[46]);
+ b = HH(b, c, d, a, M_offset_2, 23, T[47]);
+
+ a = II(a, b, c, d, M_offset_0, 6, T[48]);
+ d = II(d, a, b, c, M_offset_7, 10, T[49]);
+ c = II(c, d, a, b, M_offset_14, 15, T[50]);
+ b = II(b, c, d, a, M_offset_5, 21, T[51]);
+ a = II(a, b, c, d, M_offset_12, 6, T[52]);
+ d = II(d, a, b, c, M_offset_3, 10, T[53]);
+ c = II(c, d, a, b, M_offset_10, 15, T[54]);
+ b = II(b, c, d, a, M_offset_1, 21, T[55]);
+ a = II(a, b, c, d, M_offset_8, 6, T[56]);
+ d = II(d, a, b, c, M_offset_15, 10, T[57]);
+ c = II(c, d, a, b, M_offset_6, 15, T[58]);
+ b = II(b, c, d, a, M_offset_13, 21, T[59]);
+ a = II(a, b, c, d, M_offset_4, 6, T[60]);
+ d = II(d, a, b, c, M_offset_11, 10, T[61]);
+ c = II(c, d, a, b, M_offset_2, 15, T[62]);
+ b = II(b, c, d, a, M_offset_9, 21, T[63]);
+
+ // Intermediate hash value
+ H[0] = (H[0] + a) | 0;
+ H[1] = (H[1] + b) | 0;
+ H[2] = (H[2] + c) | 0;
+ H[3] = (H[3] + d) | 0;
+ },
+
+ _doFinalize: function () {
+ // Shortcuts
+ var data = this._data;
+ var dataWords = data.words;
+
+ var nBitsTotal = this._nDataBytes * 8;
+ var nBitsLeft = data.sigBytes * 8;
+
+ // Add padding
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+
+ var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
+ var nBitsTotalL = nBitsTotal;
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
+ (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
+ (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
+ );
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
+ (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
+ (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
+ );
+
+ data.sigBytes = (dataWords.length + 1) * 4;
+
+ // Hash final blocks
+ this._process();
+
+ // Shortcuts
+ var hash = this._hash;
+ var H = hash.words;
+
+ // Swap endian
+ for (var i = 0; i < 4; i++) {
+ // Shortcut
+ var H_i = H[i];
+
+ H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
+ (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
+ }
+
+ // Return final computed hash
+ return hash;
+ },
+
+ clone: function () {
+ var clone = Hasher.clone.call(this);
+ clone._hash = this._hash.clone();
+
+ return clone;
+ }
+ });
+
+ function FF(a, b, c, d, x, s, t) {
+ var n = a + ((b & c) | (~b & d)) + x + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ }
+
+ function GG(a, b, c, d, x, s, t) {
+ var n = a + ((b & d) | (c & ~d)) + x + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ }
+
+ function HH(a, b, c, d, x, s, t) {
+ var n = a + (b ^ c ^ d) + x + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ }
+
+ function II(a, b, c, d, x, s, t) {
+ var n = a + (c ^ (b | ~d)) + x + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ }
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.MD5('message');
+ * var hash = CryptoJS.MD5(wordArray);
+ */
+ C.MD5 = Hasher._createHelper(MD5);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacMD5(message, key);
+ */
+ C.HmacMD5 = Hasher._createHmacHelper(MD5);
+ }(Math));
+
+
+ return CryptoJS.MD5;
+
+}));
+},{"./core":51}],60:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * Cipher Feedback block mode.
+ */
+ CryptoJS.mode.CFB = (function () {
+ var CFB = CryptoJS.lib.BlockCipherMode.extend();
+
+ CFB.Encryptor = CFB.extend({
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher;
+ var blockSize = cipher.blockSize;
+
+ generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
+
+ // Remember this block to use with next block
+ this._prevBlock = words.slice(offset, offset + blockSize);
+ }
+ });
+
+ CFB.Decryptor = CFB.extend({
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher;
+ var blockSize = cipher.blockSize;
+
+ // Remember this block to use with next block
+ var thisBlock = words.slice(offset, offset + blockSize);
+
+ generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
+
+ // This block becomes the previous block
+ this._prevBlock = thisBlock;
+ }
+ });
+
+ function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
+ // Shortcut
+ var iv = this._iv;
+
+ // Generate keystream
+ if (iv) {
+ var keystream = iv.slice(0);
+
+ // Remove IV for subsequent blocks
+ this._iv = undefined;
+ } else {
+ var keystream = this._prevBlock;
+ }
+ cipher.encryptBlock(keystream, 0);
+
+ // Encrypt
+ for (var i = 0; i < blockSize; i++) {
+ words[offset + i] ^= keystream[i];
+ }
+ }
+
+ return CFB;
+ }());
+
+
+ return CryptoJS.mode.CFB;
+
+}));
+},{"./cipher-core":50,"./core":51}],61:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /** @preserve
+ * Counter block mode compatible with Dr Brian Gladman fileenc.c
+ * derived from CryptoJS.mode.CTR
+ * Jan Hruby jhruby.web@gmail.com
+ */
+ CryptoJS.mode.CTRGladman = (function () {
+ var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
+
+ function incWord(word)
+ {
+ if (((word >> 24) & 0xff) === 0xff) { //overflow
+ var b1 = (word >> 16)&0xff;
+ var b2 = (word >> 8)&0xff;
+ var b3 = word & 0xff;
+
+ if (b1 === 0xff) // overflow b1
+ {
+ b1 = 0;
+ if (b2 === 0xff)
+ {
+ b2 = 0;
+ if (b3 === 0xff)
+ {
+ b3 = 0;
+ }
+ else
+ {
+ ++b3;
+ }
+ }
+ else
+ {
+ ++b2;
+ }
+ }
+ else
+ {
+ ++b1;
+ }
+
+ word = 0;
+ word += (b1 << 16);
+ word += (b2 << 8);
+ word += b3;
+ }
+ else
+ {
+ word += (0x01 << 24);
+ }
+ return word;
+ }
+
+ function incCounter(counter)
+ {
+ if ((counter[0] = incWord(counter[0])) === 0)
+ {
+ // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
+ counter[1] = incWord(counter[1]);
+ }
+ return counter;
+ }
+
+ var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher
+ var blockSize = cipher.blockSize;
+ var iv = this._iv;
+ var counter = this._counter;
+
+ // Generate keystream
+ if (iv) {
+ counter = this._counter = iv.slice(0);
+
+ // Remove IV for subsequent blocks
+ this._iv = undefined;
+ }
+
+ incCounter(counter);
+
+ var keystream = counter.slice(0);
+ cipher.encryptBlock(keystream, 0);
+
+ // Encrypt
+ for (var i = 0; i < blockSize; i++) {
+ words[offset + i] ^= keystream[i];
+ }
+ }
+ });
+
+ CTRGladman.Decryptor = Encryptor;
+
+ return CTRGladman;
+ }());
+
+
+
+
+ return CryptoJS.mode.CTRGladman;
+
+}));
+},{"./cipher-core":50,"./core":51}],62:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * Counter block mode.
+ */
+ CryptoJS.mode.CTR = (function () {
+ var CTR = CryptoJS.lib.BlockCipherMode.extend();
+
+ var Encryptor = CTR.Encryptor = CTR.extend({
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher
+ var blockSize = cipher.blockSize;
+ var iv = this._iv;
+ var counter = this._counter;
+
+ // Generate keystream
+ if (iv) {
+ counter = this._counter = iv.slice(0);
+
+ // Remove IV for subsequent blocks
+ this._iv = undefined;
+ }
+ var keystream = counter.slice(0);
+ cipher.encryptBlock(keystream, 0);
+
+ // Increment counter
+ counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
+
+ // Encrypt
+ for (var i = 0; i < blockSize; i++) {
+ words[offset + i] ^= keystream[i];
+ }
+ }
+ });
+
+ CTR.Decryptor = Encryptor;
+
+ return CTR;
+ }());
+
+
+ return CryptoJS.mode.CTR;
+
+}));
+},{"./cipher-core":50,"./core":51}],63:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * Electronic Codebook block mode.
+ */
+ CryptoJS.mode.ECB = (function () {
+ var ECB = CryptoJS.lib.BlockCipherMode.extend();
+
+ ECB.Encryptor = ECB.extend({
+ processBlock: function (words, offset) {
+ this._cipher.encryptBlock(words, offset);
+ }
+ });
+
+ ECB.Decryptor = ECB.extend({
+ processBlock: function (words, offset) {
+ this._cipher.decryptBlock(words, offset);
+ }
+ });
+
+ return ECB;
+ }());
+
+
+ return CryptoJS.mode.ECB;
+
+}));
+},{"./cipher-core":50,"./core":51}],64:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * Output Feedback block mode.
+ */
+ CryptoJS.mode.OFB = (function () {
+ var OFB = CryptoJS.lib.BlockCipherMode.extend();
+
+ var Encryptor = OFB.Encryptor = OFB.extend({
+ processBlock: function (words, offset) {
+ // Shortcuts
+ var cipher = this._cipher
+ var blockSize = cipher.blockSize;
+ var iv = this._iv;
+ var keystream = this._keystream;
+
+ // Generate keystream
+ if (iv) {
+ keystream = this._keystream = iv.slice(0);
+
+ // Remove IV for subsequent blocks
+ this._iv = undefined;
+ }
+ cipher.encryptBlock(keystream, 0);
+
+ // Encrypt
+ for (var i = 0; i < blockSize; i++) {
+ words[offset + i] ^= keystream[i];
+ }
+ }
+ });
+
+ OFB.Decryptor = Encryptor;
+
+ return OFB;
+ }());
+
+
+ return CryptoJS.mode.OFB;
+
+}));
+},{"./cipher-core":50,"./core":51}],65:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * ANSI X.923 padding strategy.
+ */
+ CryptoJS.pad.AnsiX923 = {
+ pad: function (data, blockSize) {
+ // Shortcuts
+ var dataSigBytes = data.sigBytes;
+ var blockSizeBytes = blockSize * 4;
+
+ // Count padding bytes
+ var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
+
+ // Compute last byte position
+ var lastBytePos = dataSigBytes + nPaddingBytes - 1;
+
+ // Pad
+ data.clamp();
+ data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
+ data.sigBytes += nPaddingBytes;
+ },
+
+ unpad: function (data) {
+ // Get number of padding bytes from last byte
+ var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
+
+ // Remove padding
+ data.sigBytes -= nPaddingBytes;
+ }
+ };
+
+
+ return CryptoJS.pad.Ansix923;
+
+}));
+},{"./cipher-core":50,"./core":51}],66:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * ISO 10126 padding strategy.
+ */
+ CryptoJS.pad.Iso10126 = {
+ pad: function (data, blockSize) {
+ // Shortcut
+ var blockSizeBytes = blockSize * 4;
+
+ // Count padding bytes
+ var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
+
+ // Pad
+ data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
+ concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
+ },
+
+ unpad: function (data) {
+ // Get number of padding bytes from last byte
+ var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
+
+ // Remove padding
+ data.sigBytes -= nPaddingBytes;
+ }
+ };
+
+
+ return CryptoJS.pad.Iso10126;
+
+}));
+},{"./cipher-core":50,"./core":51}],67:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * ISO/IEC 9797-1 Padding Method 2.
+ */
+ CryptoJS.pad.Iso97971 = {
+ pad: function (data, blockSize) {
+ // Add 0x80 byte
+ data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
+
+ // Zero pad the rest
+ CryptoJS.pad.ZeroPadding.pad(data, blockSize);
+ },
+
+ unpad: function (data) {
+ // Remove zero padding
+ CryptoJS.pad.ZeroPadding.unpad(data);
+
+ // Remove one more byte -- the 0x80 byte
+ data.sigBytes--;
+ }
+ };
+
+
+ return CryptoJS.pad.Iso97971;
+
+}));
+},{"./cipher-core":50,"./core":51}],68:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * A noop padding strategy.
+ */
+ CryptoJS.pad.NoPadding = {
+ pad: function () {
+ },
+
+ unpad: function () {
+ }
+ };
+
+
+ return CryptoJS.pad.NoPadding;
+
+}));
+},{"./cipher-core":50,"./core":51}],69:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /**
+ * Zero padding strategy.
+ */
+ CryptoJS.pad.ZeroPadding = {
+ pad: function (data, blockSize) {
+ // Shortcut
+ var blockSizeBytes = blockSize * 4;
+
+ // Pad
+ data.clamp();
+ data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
+ },
+
+ unpad: function (data) {
+ // Shortcut
+ var dataWords = data.words;
+
+ // Unpad
+ var i = data.sigBytes - 1;
+ while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
+ i--;
+ }
+ data.sigBytes = i + 1;
+ }
+ };
+
+
+ return CryptoJS.pad.ZeroPadding;
+
+}));
+},{"./cipher-core":50,"./core":51}],70:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./sha1", "./hmac"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var Base = C_lib.Base;
+ var WordArray = C_lib.WordArray;
+ var C_algo = C.algo;
+ var SHA1 = C_algo.SHA1;
+ var HMAC = C_algo.HMAC;
+
+ /**
+ * Password-Based Key Derivation Function 2 algorithm.
+ */
+ var PBKDF2 = C_algo.PBKDF2 = Base.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
+ * @property {Hasher} hasher The hasher to use. Default: SHA1
+ * @property {number} iterations The number of iterations to perform. Default: 1
+ */
+ cfg: Base.extend({
+ keySize: 128/32,
+ hasher: SHA1,
+ iterations: 1
+ }),
+
+ /**
+ * Initializes a newly created key derivation function.
+ *
+ * @param {Object} cfg (Optional) The configuration options to use for the derivation.
+ *
+ * @example
+ *
+ * var kdf = CryptoJS.algo.PBKDF2.create();
+ * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
+ * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
+ */
+ init: function (cfg) {
+ this.cfg = this.cfg.extend(cfg);
+ },
+
+ /**
+ * Computes the Password-Based Key Derivation Function 2.
+ *
+ * @param {WordArray|string} password The password.
+ * @param {WordArray|string} salt A salt.
+ *
+ * @return {WordArray} The derived key.
+ *
+ * @example
+ *
+ * var key = kdf.compute(password, salt);
+ */
+ compute: function (password, salt) {
+ // Shortcut
+ var cfg = this.cfg;
+
+ // Init HMAC
+ var hmac = HMAC.create(cfg.hasher, password);
+
+ // Initial values
+ var derivedKey = WordArray.create();
+ var blockIndex = WordArray.create([0x00000001]);
+
+ // Shortcuts
+ var derivedKeyWords = derivedKey.words;
+ var blockIndexWords = blockIndex.words;
+ var keySize = cfg.keySize;
+ var iterations = cfg.iterations;
+
+ // Generate key
+ while (derivedKeyWords.length < keySize) {
+ var block = hmac.update(salt).finalize(blockIndex);
+ hmac.reset();
+
+ // Shortcuts
+ var blockWords = block.words;
+ var blockWordsLength = blockWords.length;
+
+ // Iterations
+ var intermediate = block;
+ for (var i = 1; i < iterations; i++) {
+ intermediate = hmac.finalize(intermediate);
+ hmac.reset();
+
+ // Shortcut
+ var intermediateWords = intermediate.words;
+
+ // XOR intermediate with block
+ for (var j = 0; j < blockWordsLength; j++) {
+ blockWords[j] ^= intermediateWords[j];
+ }
+ }
+
+ derivedKey.concat(block);
+ blockIndexWords[0]++;
+ }
+ derivedKey.sigBytes = keySize * 4;
+
+ return derivedKey;
+ }
+ });
+
+ /**
+ * Computes the Password-Based Key Derivation Function 2.
+ *
+ * @param {WordArray|string} password The password.
+ * @param {WordArray|string} salt A salt.
+ * @param {Object} cfg (Optional) The configuration options to use for this computation.
+ *
+ * @return {WordArray} The derived key.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var key = CryptoJS.PBKDF2(password, salt);
+ * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
+ * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
+ */
+ C.PBKDF2 = function (password, salt, cfg) {
+ return PBKDF2.create(cfg).compute(password, salt);
+ };
+ }());
+
+
+ return CryptoJS.PBKDF2;
+
+}));
+},{"./core":51,"./hmac":56,"./sha1":75}],71:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var StreamCipher = C_lib.StreamCipher;
+ var C_algo = C.algo;
+
+ // Reusable objects
+ var S = [];
+ var C_ = [];
+ var G = [];
+
+ /**
+ * Rabbit stream cipher algorithm.
+ *
+ * This is a legacy version that neglected to convert the key to little-endian.
+ * This error doesn't affect the cipher's security,
+ * but it does affect its compatibility with other implementations.
+ */
+ var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var K = this._key.words;
+ var iv = this.cfg.iv;
+
+ // Generate initial state values
+ var X = this._X = [
+ K[0], (K[3] << 16) | (K[2] >>> 16),
+ K[1], (K[0] << 16) | (K[3] >>> 16),
+ K[2], (K[1] << 16) | (K[0] >>> 16),
+ K[3], (K[2] << 16) | (K[1] >>> 16)
+ ];
+
+ // Generate initial counter values
+ var C = this._C = [
+ (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
+ (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
+ (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
+ (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
+ ];
+
+ // Carry bit
+ this._b = 0;
+
+ // Iterate the system four times
+ for (var i = 0; i < 4; i++) {
+ nextState.call(this);
+ }
+
+ // Modify the counters
+ for (var i = 0; i < 8; i++) {
+ C[i] ^= X[(i + 4) & 7];
+ }
+
+ // IV setup
+ if (iv) {
+ // Shortcuts
+ var IV = iv.words;
+ var IV_0 = IV[0];
+ var IV_1 = IV[1];
+
+ // Generate four subvectors
+ var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
+ var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
+ var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
+ var i3 = (i2 << 16) | (i0 & 0x0000ffff);
+
+ // Modify counter values
+ C[0] ^= i0;
+ C[1] ^= i1;
+ C[2] ^= i2;
+ C[3] ^= i3;
+ C[4] ^= i0;
+ C[5] ^= i1;
+ C[6] ^= i2;
+ C[7] ^= i3;
+
+ // Iterate the system four times
+ for (var i = 0; i < 4; i++) {
+ nextState.call(this);
+ }
+ }
+ },
+
+ _doProcessBlock: function (M, offset) {
+ // Shortcut
+ var X = this._X;
+
+ // Iterate the system
+ nextState.call(this);
+
+ // Generate four keystream words
+ S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
+ S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
+ S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
+ S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
+
+ for (var i = 0; i < 4; i++) {
+ // Swap endian
+ S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
+ (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
+
+ // Encrypt
+ M[offset + i] ^= S[i];
+ }
+ },
+
+ blockSize: 128/32,
+
+ ivSize: 64/32
+ });
+
+ function nextState() {
+ // Shortcuts
+ var X = this._X;
+ var C = this._C;
+
+ // Save old counter values
+ for (var i = 0; i < 8; i++) {
+ C_[i] = C[i];
+ }
+
+ // Calculate new counter values
+ C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
+ C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
+ C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
+ C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
+ C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
+ C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
+ C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
+ C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
+ this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
+
+ // Calculate the g-values
+ for (var i = 0; i < 8; i++) {
+ var gx = X[i] + C[i];
+
+ // Construct high and low argument for squaring
+ var ga = gx & 0xffff;
+ var gb = gx >>> 16;
+
+ // Calculate high and low result of squaring
+ var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
+ var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
+
+ // High XOR low
+ G[i] = gh ^ gl;
+ }
+
+ // Calculate new state values
+ X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
+ X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
+ X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
+ X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
+ X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
+ X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
+ X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
+ X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
+ }
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
+ */
+ C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
+ }());
+
+
+ return CryptoJS.RabbitLegacy;
+
+}));
+},{"./cipher-core":50,"./core":51,"./enc-base64":52,"./evpkdf":54,"./md5":59}],72:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var StreamCipher = C_lib.StreamCipher;
+ var C_algo = C.algo;
+
+ // Reusable objects
+ var S = [];
+ var C_ = [];
+ var G = [];
+
+ /**
+ * Rabbit stream cipher algorithm
+ */
+ var Rabbit = C_algo.Rabbit = StreamCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var K = this._key.words;
+ var iv = this.cfg.iv;
+
+ // Swap endian
+ for (var i = 0; i < 4; i++) {
+ K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
+ (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
+ }
+
+ // Generate initial state values
+ var X = this._X = [
+ K[0], (K[3] << 16) | (K[2] >>> 16),
+ K[1], (K[0] << 16) | (K[3] >>> 16),
+ K[2], (K[1] << 16) | (K[0] >>> 16),
+ K[3], (K[2] << 16) | (K[1] >>> 16)
+ ];
+
+ // Generate initial counter values
+ var C = this._C = [
+ (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
+ (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
+ (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
+ (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
+ ];
+
+ // Carry bit
+ this._b = 0;
+
+ // Iterate the system four times
+ for (var i = 0; i < 4; i++) {
+ nextState.call(this);
+ }
+
+ // Modify the counters
+ for (var i = 0; i < 8; i++) {
+ C[i] ^= X[(i + 4) & 7];
+ }
+
+ // IV setup
+ if (iv) {
+ // Shortcuts
+ var IV = iv.words;
+ var IV_0 = IV[0];
+ var IV_1 = IV[1];
+
+ // Generate four subvectors
+ var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
+ var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
+ var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
+ var i3 = (i2 << 16) | (i0 & 0x0000ffff);
+
+ // Modify counter values
+ C[0] ^= i0;
+ C[1] ^= i1;
+ C[2] ^= i2;
+ C[3] ^= i3;
+ C[4] ^= i0;
+ C[5] ^= i1;
+ C[6] ^= i2;
+ C[7] ^= i3;
+
+ // Iterate the system four times
+ for (var i = 0; i < 4; i++) {
+ nextState.call(this);
+ }
+ }
+ },
+
+ _doProcessBlock: function (M, offset) {
+ // Shortcut
+ var X = this._X;
+
+ // Iterate the system
+ nextState.call(this);
+
+ // Generate four keystream words
+ S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
+ S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
+ S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
+ S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
+
+ for (var i = 0; i < 4; i++) {
+ // Swap endian
+ S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
+ (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
+
+ // Encrypt
+ M[offset + i] ^= S[i];
+ }
+ },
+
+ blockSize: 128/32,
+
+ ivSize: 64/32
+ });
+
+ function nextState() {
+ // Shortcuts
+ var X = this._X;
+ var C = this._C;
+
+ // Save old counter values
+ for (var i = 0; i < 8; i++) {
+ C_[i] = C[i];
+ }
+
+ // Calculate new counter values
+ C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
+ C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
+ C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
+ C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
+ C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
+ C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
+ C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
+ C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
+ this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
+
+ // Calculate the g-values
+ for (var i = 0; i < 8; i++) {
+ var gx = X[i] + C[i];
+
+ // Construct high and low argument for squaring
+ var ga = gx & 0xffff;
+ var gb = gx >>> 16;
+
+ // Calculate high and low result of squaring
+ var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
+ var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
+
+ // High XOR low
+ G[i] = gh ^ gl;
+ }
+
+ // Calculate new state values
+ X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
+ X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
+ X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
+ X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
+ X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
+ X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
+ X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
+ X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
+ }
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
+ */
+ C.Rabbit = StreamCipher._createHelper(Rabbit);
+ }());
+
+
+ return CryptoJS.Rabbit;
+
+}));
+},{"./cipher-core":50,"./core":51,"./enc-base64":52,"./evpkdf":54,"./md5":59}],73:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var StreamCipher = C_lib.StreamCipher;
+ var C_algo = C.algo;
+
+ /**
+ * RC4 stream cipher algorithm.
+ */
+ var RC4 = C_algo.RC4 = StreamCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var key = this._key;
+ var keyWords = key.words;
+ var keySigBytes = key.sigBytes;
+
+ // Init sbox
+ var S = this._S = [];
+ for (var i = 0; i < 256; i++) {
+ S[i] = i;
+ }
+
+ // Key setup
+ for (var i = 0, j = 0; i < 256; i++) {
+ var keyByteIndex = i % keySigBytes;
+ var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
+
+ j = (j + S[i] + keyByte) % 256;
+
+ // Swap
+ var t = S[i];
+ S[i] = S[j];
+ S[j] = t;
+ }
+
+ // Counters
+ this._i = this._j = 0;
+ },
+
+ _doProcessBlock: function (M, offset) {
+ M[offset] ^= generateKeystreamWord.call(this);
+ },
+
+ keySize: 256/32,
+
+ ivSize: 0
+ });
+
+ function generateKeystreamWord() {
+ // Shortcuts
+ var S = this._S;
+ var i = this._i;
+ var j = this._j;
+
+ // Generate keystream word
+ var keystreamWord = 0;
+ for (var n = 0; n < 4; n++) {
+ i = (i + 1) % 256;
+ j = (j + S[i]) % 256;
+
+ // Swap
+ var t = S[i];
+ S[i] = S[j];
+ S[j] = t;
+
+ keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
+ }
+
+ // Update counters
+ this._i = i;
+ this._j = j;
+
+ return keystreamWord;
+ }
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
+ */
+ C.RC4 = StreamCipher._createHelper(RC4);
+
+ /**
+ * Modified RC4 stream cipher algorithm.
+ */
+ var RC4Drop = C_algo.RC4Drop = RC4.extend({
+ /**
+ * Configuration options.
+ *
+ * @property {number} drop The number of keystream words to drop. Default 192
+ */
+ cfg: RC4.cfg.extend({
+ drop: 192
+ }),
+
+ _doReset: function () {
+ RC4._doReset.call(this);
+
+ // Drop
+ for (var i = this.cfg.drop; i > 0; i--) {
+ generateKeystreamWord.call(this);
+ }
+ }
+ });
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
+ */
+ C.RC4Drop = StreamCipher._createHelper(RC4Drop);
+ }());
+
+
+ return CryptoJS.RC4;
+
+}));
+},{"./cipher-core":50,"./core":51,"./enc-base64":52,"./evpkdf":54,"./md5":59}],74:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ /** @preserve
+ (c) 2012 by Cédric Mesnil. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ - 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.
+
+ 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.
+ */
+
+ (function (Math) {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var Hasher = C_lib.Hasher;
+ var C_algo = C.algo;
+
+ // Constants table
+ var _zl = WordArray.create([
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
+ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
+ var _zr = WordArray.create([
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
+ 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
+ var _sl = WordArray.create([
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
+ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
+ var _sr = WordArray.create([
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
+ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
+
+ var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
+ var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
+
+ /**
+ * RIPEMD160 hash algorithm.
+ */
+ var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
+ _doReset: function () {
+ this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
+ },
+
+ _doProcessBlock: function (M, offset) {
+
+ // Swap endian
+ for (var i = 0; i < 16; i++) {
+ // Shortcuts
+ var offset_i = offset + i;
+ var M_offset_i = M[offset_i];
+
+ // Swap
+ M[offset_i] = (
+ (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
+ (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
+ );
+ }
+ // Shortcut
+ var H = this._hash.words;
+ var hl = _hl.words;
+ var hr = _hr.words;
+ var zl = _zl.words;
+ var zr = _zr.words;
+ var sl = _sl.words;
+ var sr = _sr.words;
+
+ // Working variables
+ var al, bl, cl, dl, el;
+ var ar, br, cr, dr, er;
+
+ ar = al = H[0];
+ br = bl = H[1];
+ cr = cl = H[2];
+ dr = dl = H[3];
+ er = el = H[4];
+ // Computation
+ var t;
+ for (var i = 0; i < 80; i += 1) {
+ t = (al + M[offset+zl[i]])|0;
+ if (i<16){
+ t += f1(bl,cl,dl) + hl[0];
+ } else if (i<32) {
+ t += f2(bl,cl,dl) + hl[1];
+ } else if (i<48) {
+ t += f3(bl,cl,dl) + hl[2];
+ } else if (i<64) {
+ t += f4(bl,cl,dl) + hl[3];
+ } else {// if (i<80) {
+ t += f5(bl,cl,dl) + hl[4];
+ }
+ t = t|0;
+ t = rotl(t,sl[i]);
+ t = (t+el)|0;
+ al = el;
+ el = dl;
+ dl = rotl(cl, 10);
+ cl = bl;
+ bl = t;
+
+ t = (ar + M[offset+zr[i]])|0;
+ if (i<16){
+ t += f5(br,cr,dr) + hr[0];
+ } else if (i<32) {
+ t += f4(br,cr,dr) + hr[1];
+ } else if (i<48) {
+ t += f3(br,cr,dr) + hr[2];
+ } else if (i<64) {
+ t += f2(br,cr,dr) + hr[3];
+ } else {// if (i<80) {
+ t += f1(br,cr,dr) + hr[4];
+ }
+ t = t|0;
+ t = rotl(t,sr[i]) ;
+ t = (t+er)|0;
+ ar = er;
+ er = dr;
+ dr = rotl(cr, 10);
+ cr = br;
+ br = t;
+ }
+ // Intermediate hash value
+ t = (H[1] + cl + dr)|0;
+ H[1] = (H[2] + dl + er)|0;
+ H[2] = (H[3] + el + ar)|0;
+ H[3] = (H[4] + al + br)|0;
+ H[4] = (H[0] + bl + cr)|0;
+ H[0] = t;
+ },
+
+ _doFinalize: function () {
+ // Shortcuts
+ var data = this._data;
+ var dataWords = data.words;
+
+ var nBitsTotal = this._nDataBytes * 8;
+ var nBitsLeft = data.sigBytes * 8;
+
+ // Add padding
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
+ (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
+ (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
+ );
+ data.sigBytes = (dataWords.length + 1) * 4;
+
+ // Hash final blocks
+ this._process();
+
+ // Shortcuts
+ var hash = this._hash;
+ var H = hash.words;
+
+ // Swap endian
+ for (var i = 0; i < 5; i++) {
+ // Shortcut
+ var H_i = H[i];
+
+ // Swap
+ H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
+ (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
+ }
+
+ // Return final computed hash
+ return hash;
+ },
+
+ clone: function () {
+ var clone = Hasher.clone.call(this);
+ clone._hash = this._hash.clone();
+
+ return clone;
+ }
+ });
+
+
+ function f1(x, y, z) {
+ return ((x) ^ (y) ^ (z));
+
+ }
+
+ function f2(x, y, z) {
+ return (((x)&(y)) | ((~x)&(z)));
+ }
+
+ function f3(x, y, z) {
+ return (((x) | (~(y))) ^ (z));
+ }
+
+ function f4(x, y, z) {
+ return (((x) & (z)) | ((y)&(~(z))));
+ }
+
+ function f5(x, y, z) {
+ return ((x) ^ ((y) |(~(z))));
+
+ }
+
+ function rotl(x,n) {
+ return (x<<n) | (x>>>(32-n));
+ }
+
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.RIPEMD160('message');
+ * var hash = CryptoJS.RIPEMD160(wordArray);
+ */
+ C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacRIPEMD160(message, key);
+ */
+ C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
+ }(Math));
+
+
+ return CryptoJS.RIPEMD160;
+
+}));
+},{"./core":51}],75:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var Hasher = C_lib.Hasher;
+ var C_algo = C.algo;
+
+ // Reusable object
+ var W = [];
+
+ /**
+ * SHA-1 hash algorithm.
+ */
+ var SHA1 = C_algo.SHA1 = Hasher.extend({
+ _doReset: function () {
+ this._hash = new WordArray.init([
+ 0x67452301, 0xefcdab89,
+ 0x98badcfe, 0x10325476,
+ 0xc3d2e1f0
+ ]);
+ },
+
+ _doProcessBlock: function (M, offset) {
+ // Shortcut
+ var H = this._hash.words;
+
+ // Working variables
+ var a = H[0];
+ var b = H[1];
+ var c = H[2];
+ var d = H[3];
+ var e = H[4];
+
+ // Computation
+ for (var i = 0; i < 80; i++) {
+ if (i < 16) {
+ W[i] = M[offset + i] | 0;
+ } else {
+ var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
+ W[i] = (n << 1) | (n >>> 31);
+ }
+
+ var t = ((a << 5) | (a >>> 27)) + e + W[i];
+ if (i < 20) {
+ t += ((b & c) | (~b & d)) + 0x5a827999;
+ } else if (i < 40) {
+ t += (b ^ c ^ d) + 0x6ed9eba1;
+ } else if (i < 60) {
+ t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
+ } else /* if (i < 80) */ {
+ t += (b ^ c ^ d) - 0x359d3e2a;
+ }
+
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+
+ // Intermediate hash value
+ H[0] = (H[0] + a) | 0;
+ H[1] = (H[1] + b) | 0;
+ H[2] = (H[2] + c) | 0;
+ H[3] = (H[3] + d) | 0;
+ H[4] = (H[4] + e) | 0;
+ },
+
+ _doFinalize: function () {
+ // Shortcuts
+ var data = this._data;
+ var dataWords = data.words;
+
+ var nBitsTotal = this._nDataBytes * 8;
+ var nBitsLeft = data.sigBytes * 8;
+
+ // Add padding
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
+ data.sigBytes = dataWords.length * 4;
+
+ // Hash final blocks
+ this._process();
+
+ // Return final computed hash
+ return this._hash;
+ },
+
+ clone: function () {
+ var clone = Hasher.clone.call(this);
+ clone._hash = this._hash.clone();
+
+ return clone;
+ }
+ });
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.SHA1('message');
+ * var hash = CryptoJS.SHA1(wordArray);
+ */
+ C.SHA1 = Hasher._createHelper(SHA1);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacSHA1(message, key);
+ */
+ C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
+ }());
+
+
+ return CryptoJS.SHA1;
+
+}));
+},{"./core":51}],76:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./sha256"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./sha256"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var C_algo = C.algo;
+ var SHA256 = C_algo.SHA256;
+
+ /**
+ * SHA-224 hash algorithm.
+ */
+ var SHA224 = C_algo.SHA224 = SHA256.extend({
+ _doReset: function () {
+ this._hash = new WordArray.init([
+ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
+ 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
+ ]);
+ },
+
+ _doFinalize: function () {
+ var hash = SHA256._doFinalize.call(this);
+
+ hash.sigBytes -= 4;
+
+ return hash;
+ }
+ });
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.SHA224('message');
+ * var hash = CryptoJS.SHA224(wordArray);
+ */
+ C.SHA224 = SHA256._createHelper(SHA224);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacSHA224(message, key);
+ */
+ C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
+ }());
+
+
+ return CryptoJS.SHA224;
+
+}));
+},{"./core":51,"./sha256":77}],77:[function(require,module,exports){
+;(function (root, factory) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function (Math) {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var Hasher = C_lib.Hasher;
+ var C_algo = C.algo;
+
+ // Initialization and round constants tables
+ var H = [];
+ var K = [];
+
+ // Compute constants
+ (function () {
+ function isPrime(n) {
+ var sqrtN = Math.sqrt(n);
+ for (var factor = 2; factor <= sqrtN; factor++) {
+ if (!(n % factor)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ function getFractionalBits(n) {
+ return ((n - (n | 0)) * 0x100000000) | 0;
+ }
+
+ var n = 2;
+ var nPrime = 0;
+ while (nPrime < 64) {
+ if (isPrime(n)) {
+ if (nPrime < 8) {
+ H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
+ }
+ K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
+
+ nPrime++;
+ }
+
+ n++;
+ }
+ }());
+
+ // Reusable object
+ var W = [];
+
+ /**
+ * SHA-256 hash algorithm.
+ */
+ var SHA256 = C_algo.SHA256 = Hasher.extend({
+ _doReset: function () {
+ this._hash = new WordArray.init(H.slice(0));
+ },
+
+ _doProcessBlock: function (M, offset) {
+ // Shortcut
+ var H = this._hash.words;
+
+ // Working variables
+ var a = H[0];
+ var b = H[1];
+ var c = H[2];
+ var d = H[3];
+ var e = H[4];
+ var f = H[5];
+ var g = H[6];
+ var h = H[7];
+
+ // Computation
+ for (var i = 0; i < 64; i++) {
+ if (i < 16) {
+ W[i] = M[offset + i] | 0;
+ } else {
+ var gamma0x = W[i - 15];
+ var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
+ ((gamma0x << 14) | (gamma0x >>> 18)) ^
+ (gamma0x >>> 3);
+
+ var gamma1x = W[i - 2];
+ var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
+ ((gamma1x << 13) | (gamma1x >>> 19)) ^
+ (gamma1x >>> 10);
+
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
+ }
+
+ var ch = (e & f) ^ (~e & g);
+ var maj = (a & b) ^ (a & c) ^ (b & c);
+
+ var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
+ var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
+
+ var t1 = h + sigma1 + ch + K[i] + W[i];
+ var t2 = sigma0 + maj;
+
+ h = g;
+ g = f;
+ f = e;
+ e = (d + t1) | 0;
+ d = c;
+ c = b;
+ b = a;
+ a = (t1 + t2) | 0;
+ }
+
+ // Intermediate hash value
+ H[0] = (H[0] + a) | 0;
+ H[1] = (H[1] + b) | 0;
+ H[2] = (H[2] + c) | 0;
+ H[3] = (H[3] + d) | 0;
+ H[4] = (H[4] + e) | 0;
+ H[5] = (H[5] + f) | 0;
+ H[6] = (H[6] + g) | 0;
+ H[7] = (H[7] + h) | 0;
+ },
+
+ _doFinalize: function () {
+ // Shortcuts
+ var data = this._data;
+ var dataWords = data.words;
+
+ var nBitsTotal = this._nDataBytes * 8;
+ var nBitsLeft = data.sigBytes * 8;
+
+ // Add padding
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
+ data.sigBytes = dataWords.length * 4;
+
+ // Hash final blocks
+ this._process();
+
+ // Return final computed hash
+ return this._hash;
+ },
+
+ clone: function () {
+ var clone = Hasher.clone.call(this);
+ clone._hash = this._hash.clone();
+
+ return clone;
+ }
+ });
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.SHA256('message');
+ * var hash = CryptoJS.SHA256(wordArray);
+ */
+ C.SHA256 = Hasher._createHelper(SHA256);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacSHA256(message, key);
+ */
+ C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
+ }(Math));
+
+
+ return CryptoJS.SHA256;
+
+}));
+},{"./core":51}],78:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@@ -7242,7 +11358,1186 @@ module.exports = transfer;
return CryptoJS.SHA3;
}));
-},{"./core":47,"./x64-core":49}],49:[function(require,module,exports){
+},{"./core":51,"./x64-core":82}],79:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./x64-core", "./sha512"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_x64 = C.x64;
+ var X64Word = C_x64.Word;
+ var X64WordArray = C_x64.WordArray;
+ var C_algo = C.algo;
+ var SHA512 = C_algo.SHA512;
+
+ /**
+ * SHA-384 hash algorithm.
+ */
+ var SHA384 = C_algo.SHA384 = SHA512.extend({
+ _doReset: function () {
+ this._hash = new X64WordArray.init([
+ new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
+ new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
+ new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
+ new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
+ ]);
+ },
+
+ _doFinalize: function () {
+ var hash = SHA512._doFinalize.call(this);
+
+ hash.sigBytes -= 16;
+
+ return hash;
+ }
+ });
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.SHA384('message');
+ * var hash = CryptoJS.SHA384(wordArray);
+ */
+ C.SHA384 = SHA512._createHelper(SHA384);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacSHA384(message, key);
+ */
+ C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
+ }());
+
+
+ return CryptoJS.SHA384;
+
+}));
+},{"./core":51,"./sha512":80,"./x64-core":82}],80:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./x64-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./x64-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var Hasher = C_lib.Hasher;
+ var C_x64 = C.x64;
+ var X64Word = C_x64.Word;
+ var X64WordArray = C_x64.WordArray;
+ var C_algo = C.algo;
+
+ function X64Word_create() {
+ return X64Word.create.apply(X64Word, arguments);
+ }
+
+ // Constants
+ var K = [
+ X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
+ X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
+ X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
+ X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
+ X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
+ X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
+ X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
+ X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
+ X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
+ X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
+ X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
+ X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
+ X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
+ X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
+ X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
+ X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
+ X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
+ X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
+ X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
+ X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
+ X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
+ X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
+ X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
+ X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
+ X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
+ X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
+ X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
+ X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
+ X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
+ X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
+ X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
+ X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
+ X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
+ X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
+ X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
+ X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
+ X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
+ X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
+ X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
+ X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
+ ];
+
+ // Reusable objects
+ var W = [];
+ (function () {
+ for (var i = 0; i < 80; i++) {
+ W[i] = X64Word_create();
+ }
+ }());
+
+ /**
+ * SHA-512 hash algorithm.
+ */
+ var SHA512 = C_algo.SHA512 = Hasher.extend({
+ _doReset: function () {
+ this._hash = new X64WordArray.init([
+ new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
+ new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
+ new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
+ new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
+ ]);
+ },
+
+ _doProcessBlock: function (M, offset) {
+ // Shortcuts
+ var H = this._hash.words;
+
+ var H0 = H[0];
+ var H1 = H[1];
+ var H2 = H[2];
+ var H3 = H[3];
+ var H4 = H[4];
+ var H5 = H[5];
+ var H6 = H[6];
+ var H7 = H[7];
+
+ var H0h = H0.high;
+ var H0l = H0.low;
+ var H1h = H1.high;
+ var H1l = H1.low;
+ var H2h = H2.high;
+ var H2l = H2.low;
+ var H3h = H3.high;
+ var H3l = H3.low;
+ var H4h = H4.high;
+ var H4l = H4.low;
+ var H5h = H5.high;
+ var H5l = H5.low;
+ var H6h = H6.high;
+ var H6l = H6.low;
+ var H7h = H7.high;
+ var H7l = H7.low;
+
+ // Working variables
+ var ah = H0h;
+ var al = H0l;
+ var bh = H1h;
+ var bl = H1l;
+ var ch = H2h;
+ var cl = H2l;
+ var dh = H3h;
+ var dl = H3l;
+ var eh = H4h;
+ var el = H4l;
+ var fh = H5h;
+ var fl = H5l;
+ var gh = H6h;
+ var gl = H6l;
+ var hh = H7h;
+ var hl = H7l;
+
+ // Rounds
+ for (var i = 0; i < 80; i++) {
+ // Shortcut
+ var Wi = W[i];
+
+ // Extend message
+ if (i < 16) {
+ var Wih = Wi.high = M[offset + i * 2] | 0;
+ var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
+ } else {
+ // Gamma0
+ var gamma0x = W[i - 15];
+ var gamma0xh = gamma0x.high;
+ var gamma0xl = gamma0x.low;
+ var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
+ var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
+
+ // Gamma1
+ var gamma1x = W[i - 2];
+ var gamma1xh = gamma1x.high;
+ var gamma1xl = gamma1x.low;
+ var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
+ var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
+
+ // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
+ var Wi7 = W[i - 7];
+ var Wi7h = Wi7.high;
+ var Wi7l = Wi7.low;
+
+ var Wi16 = W[i - 16];
+ var Wi16h = Wi16.high;
+ var Wi16l = Wi16.low;
+
+ var Wil = gamma0l + Wi7l;
+ var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
+ var Wil = Wil + gamma1l;
+ var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
+ var Wil = Wil + Wi16l;
+ var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
+
+ Wi.high = Wih;
+ Wi.low = Wil;
+ }
+
+ var chh = (eh & fh) ^ (~eh & gh);
+ var chl = (el & fl) ^ (~el & gl);
+ var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
+ var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
+
+ var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
+ var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
+ var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
+ var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
+
+ // t1 = h + sigma1 + ch + K[i] + W[i]
+ var Ki = K[i];
+ var Kih = Ki.high;
+ var Kil = Ki.low;
+
+ var t1l = hl + sigma1l;
+ var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
+ var t1l = t1l + chl;
+ var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
+ var t1l = t1l + Kil;
+ var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
+ var t1l = t1l + Wil;
+ var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
+
+ // t2 = sigma0 + maj
+ var t2l = sigma0l + majl;
+ var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
+
+ // Update working variables
+ hh = gh;
+ hl = gl;
+ gh = fh;
+ gl = fl;
+ fh = eh;
+ fl = el;
+ el = (dl + t1l) | 0;
+ eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
+ dh = ch;
+ dl = cl;
+ ch = bh;
+ cl = bl;
+ bh = ah;
+ bl = al;
+ al = (t1l + t2l) | 0;
+ ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
+ }
+
+ // Intermediate hash value
+ H0l = H0.low = (H0l + al);
+ H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
+ H1l = H1.low = (H1l + bl);
+ H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
+ H2l = H2.low = (H2l + cl);
+ H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
+ H3l = H3.low = (H3l + dl);
+ H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
+ H4l = H4.low = (H4l + el);
+ H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
+ H5l = H5.low = (H5l + fl);
+ H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
+ H6l = H6.low = (H6l + gl);
+ H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
+ H7l = H7.low = (H7l + hl);
+ H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
+ },
+
+ _doFinalize: function () {
+ // Shortcuts
+ var data = this._data;
+ var dataWords = data.words;
+
+ var nBitsTotal = this._nDataBytes * 8;
+ var nBitsLeft = data.sigBytes * 8;
+
+ // Add padding
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+ dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
+ dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
+ data.sigBytes = dataWords.length * 4;
+
+ // Hash final blocks
+ this._process();
+
+ // Convert hash to 32-bit word array before returning
+ var hash = this._hash.toX32();
+
+ // Return final computed hash
+ return hash;
+ },
+
+ clone: function () {
+ var clone = Hasher.clone.call(this);
+ clone._hash = this._hash.clone();
+
+ return clone;
+ },
+
+ blockSize: 1024/32
+ });
+
+ /**
+ * Shortcut function to the hasher's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ *
+ * @return {WordArray} The hash.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hash = CryptoJS.SHA512('message');
+ * var hash = CryptoJS.SHA512(wordArray);
+ */
+ C.SHA512 = Hasher._createHelper(SHA512);
+
+ /**
+ * Shortcut function to the HMAC's object interface.
+ *
+ * @param {WordArray|string} message The message to hash.
+ * @param {WordArray|string} key The secret key.
+ *
+ * @return {WordArray} The HMAC.
+ *
+ * @static
+ *
+ * @example
+ *
+ * var hmac = CryptoJS.HmacSHA512(message, key);
+ */
+ C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
+ }());
+
+
+ return CryptoJS.SHA512;
+
+}));
+},{"./core":51,"./x64-core":82}],81:[function(require,module,exports){
+;(function (root, factory, undef) {
+ if (typeof exports === "object") {
+ // CommonJS
+ module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
+ }
+ else if (typeof define === "function" && define.amd) {
+ // AMD
+ define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
+ }
+ else {
+ // Global (browser)
+ factory(root.CryptoJS);
+ }
+}(this, function (CryptoJS) {
+
+ (function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var WordArray = C_lib.WordArray;
+ var BlockCipher = C_lib.BlockCipher;
+ var C_algo = C.algo;
+
+ // Permuted Choice 1 constants
+ var PC1 = [
+ 57, 49, 41, 33, 25, 17, 9, 1,
+ 58, 50, 42, 34, 26, 18, 10, 2,
+ 59, 51, 43, 35, 27, 19, 11, 3,
+ 60, 52, 44, 36, 63, 55, 47, 39,
+ 31, 23, 15, 7, 62, 54, 46, 38,
+ 30, 22, 14, 6, 61, 53, 45, 37,
+ 29, 21, 13, 5, 28, 20, 12, 4
+ ];
+
+ // Permuted Choice 2 constants
+ var PC2 = [
+ 14, 17, 11, 24, 1, 5,
+ 3, 28, 15, 6, 21, 10,
+ 23, 19, 12, 4, 26, 8,
+ 16, 7, 27, 20, 13, 2,
+ 41, 52, 31, 37, 47, 55,
+ 30, 40, 51, 45, 33, 48,
+ 44, 49, 39, 56, 34, 53,
+ 46, 42, 50, 36, 29, 32
+ ];
+
+ // Cumulative bit shift constants
+ var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
+
+ // SBOXes and round permutation constants
+ var SBOX_P = [
+ {
+ 0x0: 0x808200,
+ 0x10000000: 0x8000,
+ 0x20000000: 0x808002,
+ 0x30000000: 0x2,
+ 0x40000000: 0x200,
+ 0x50000000: 0x808202,
+ 0x60000000: 0x800202,
+ 0x70000000: 0x800000,
+ 0x80000000: 0x202,
+ 0x90000000: 0x800200,
+ 0xa0000000: 0x8200,
+ 0xb0000000: 0x808000,
+ 0xc0000000: 0x8002,
+ 0xd0000000: 0x800002,
+ 0xe0000000: 0x0,
+ 0xf0000000: 0x8202,
+ 0x8000000: 0x0,
+ 0x18000000: 0x808202,
+ 0x28000000: 0x8202,
+ 0x38000000: 0x8000,
+ 0x48000000: 0x808200,
+ 0x58000000: 0x200,
+ 0x68000000: 0x808002,
+ 0x78000000: 0x2,
+ 0x88000000: 0x800200,
+ 0x98000000: 0x8200,
+ 0xa8000000: 0x808000,
+ 0xb8000000: 0x800202,
+ 0xc8000000: 0x800002,
+ 0xd8000000: 0x8002,
+ 0xe8000000: 0x202,
+ 0xf8000000: 0x800000,
+ 0x1: 0x8000,
+ 0x10000001: 0x2,
+ 0x20000001: 0x808200,
+ 0x30000001: 0x800000,
+ 0x40000001: 0x808002,
+ 0x50000001: 0x8200,
+ 0x60000001: 0x200,
+ 0x70000001: 0x800202,
+ 0x80000001: 0x808202,
+ 0x90000001: 0x808000,
+ 0xa0000001: 0x800002,
+ 0xb0000001: 0x8202,
+ 0xc0000001: 0x202,
+ 0xd0000001: 0x800200,
+ 0xe0000001: 0x8002,
+ 0xf0000001: 0x0,
+ 0x8000001: 0x808202,
+ 0x18000001: 0x808000,
+ 0x28000001: 0x800000,
+ 0x38000001: 0x200,
+ 0x48000001: 0x8000,
+ 0x58000001: 0x800002,
+ 0x68000001: 0x2,
+ 0x78000001: 0x8202,
+ 0x88000001: 0x8002,
+ 0x98000001: 0x800202,
+ 0xa8000001: 0x202,
+ 0xb8000001: 0x808200,
+ 0xc8000001: 0x800200,
+ 0xd8000001: 0x0,
+ 0xe8000001: 0x8200,
+ 0xf8000001: 0x808002
+ },
+ {
+ 0x0: 0x40084010,
+ 0x1000000: 0x4000,
+ 0x2000000: 0x80000,
+ 0x3000000: 0x40080010,
+ 0x4000000: 0x40000010,
+ 0x5000000: 0x40084000,
+ 0x6000000: 0x40004000,
+ 0x7000000: 0x10,
+ 0x8000000: 0x84000,
+ 0x9000000: 0x40004010,
+ 0xa000000: 0x40000000,
+ 0xb000000: 0x84010,
+ 0xc000000: 0x80010,
+ 0xd000000: 0x0,
+ 0xe000000: 0x4010,
+ 0xf000000: 0x40080000,
+ 0x800000: 0x40004000,
+ 0x1800000: 0x84010,
+ 0x2800000: 0x10,
+ 0x3800000: 0x40004010,
+ 0x4800000: 0x40084010,
+ 0x5800000: 0x40000000,
+ 0x6800000: 0x80000,
+ 0x7800000: 0x40080010,
+ 0x8800000: 0x80010,
+ 0x9800000: 0x0,
+ 0xa800000: 0x4000,
+ 0xb800000: 0x40080000,
+ 0xc800000: 0x40000010,
+ 0xd800000: 0x84000,
+ 0xe800000: 0x40084000,
+ 0xf800000: 0x4010,
+ 0x10000000: 0x0,
+ 0x11000000: 0x40080010,
+ 0x12000000: 0x40004010,
+ 0x13000000: 0x40084000,
+ 0x14000000: 0x40080000,
+ 0x15000000: 0x10,
+ 0x16000000: 0x84010,
+ 0x17000000: 0x4000,
+ 0x18000000: 0x4010,
+ 0x19000000: 0x80000,
+ 0x1a000000: 0x80010,
+ 0x1b000000: 0x40000010,
+ 0x1c000000: 0x84000,
+ 0x1d000000: 0x40004000,
+ 0x1e000000: 0x40000000,
+ 0x1f000000: 0x40084010,
+ 0x10800000: 0x84010,
+ 0x11800000: 0x80000,
+ 0x12800000: 0x40080000,
+ 0x13800000: 0x4000,
+ 0x14800000: 0x40004000,
+ 0x15800000: 0x40084010,
+ 0x16800000: 0x10,
+ 0x17800000: 0x40000000,
+ 0x18800000: 0x40084000,
+ 0x19800000: 0x40000010,
+ 0x1a800000: 0x40004010,
+ 0x1b800000: 0x80010,
+ 0x1c800000: 0x0,
+ 0x1d800000: 0x4010,
+ 0x1e800000: 0x40080010,
+ 0x1f800000: 0x84000
+ },
+ {
+ 0x0: 0x104,
+ 0x100000: 0x0,
+ 0x200000: 0x4000100,
+ 0x300000: 0x10104,
+ 0x400000: 0x10004,
+ 0x500000: 0x4000004,
+ 0x600000: 0x4010104,
+ 0x700000: 0x4010000,
+ 0x800000: 0x4000000,
+ 0x900000: 0x4010100,
+ 0xa00000: 0x10100,
+ 0xb00000: 0x4010004,
+ 0xc00000: 0x4000104,
+ 0xd00000: 0x10000,
+ 0xe00000: 0x4,
+ 0xf00000: 0x100,
+ 0x80000: 0x4010100,
+ 0x180000: 0x4010004,
+ 0x280000: 0x0,
+ 0x380000: 0x4000100,
+ 0x480000: 0x4000004,
+ 0x580000: 0x10000,
+ 0x680000: 0x10004,
+ 0x780000: 0x104,
+ 0x880000: 0x4,
+ 0x980000: 0x100,
+ 0xa80000: 0x4010000,
+ 0xb80000: 0x10104,
+ 0xc80000: 0x10100,
+ 0xd80000: 0x4000104,
+ 0xe80000: 0x4010104,
+ 0xf80000: 0x4000000,
+ 0x1000000: 0x4010100,
+ 0x1100000: 0x10004,
+ 0x1200000: 0x10000,
+ 0x1300000: 0x4000100,
+ 0x1400000: 0x100,
+ 0x1500000: 0x4010104,
+ 0x1600000: 0x4000004,
+ 0x1700000: 0x0,
+ 0x1800000: 0x4000104,
+ 0x1900000: 0x4000000,
+ 0x1a00000: 0x4,
+ 0x1b00000: 0x10100,
+ 0x1c00000: 0x4010000,
+ 0x1d00000: 0x104,
+ 0x1e00000: 0x10104,
+ 0x1f00000: 0x4010004,
+ 0x1080000: 0x4000000,
+ 0x1180000: 0x104,
+ 0x1280000: 0x4010100,
+ 0x1380000: 0x0,
+ 0x1480000: 0x10004,
+ 0x1580000: 0x4000100,
+ 0x1680000: 0x100,
+ 0x1780000: 0x4010004,
+ 0x1880000: 0x10000,
+ 0x1980000: 0x4010104,
+ 0x1a80000: 0x10104,
+ 0x1b80000: 0x4000004,
+ 0x1c80000: 0x4000104,
+ 0x1d80000: 0x4010000,
+ 0x1e80000: 0x4,
+ 0x1f80000: 0x10100
+ },
+ {
+ 0x0: 0x80401000,
+ 0x10000: 0x80001040,
+ 0x20000: 0x401040,
+ 0x30000: 0x80400000,
+ 0x40000: 0x0,
+ 0x50000: 0x401000,
+ 0x60000: 0x80000040,
+ 0x70000: 0x400040,
+ 0x80000: 0x80000000,
+ 0x90000: 0x400000,
+ 0xa0000: 0x40,
+ 0xb0000: 0x80001000,
+ 0xc0000: 0x80400040,
+ 0xd0000: 0x1040,
+ 0xe0000: 0x1000,
+ 0xf0000: 0x80401040,
+ 0x8000: 0x80001040,
+ 0x18000: 0x40,
+ 0x28000: 0x80400040,
+ 0x38000: 0x80001000,
+ 0x48000: 0x401000,
+ 0x58000: 0x80401040,
+ 0x68000: 0x0,
+ 0x78000: 0x80400000,
+ 0x88000: 0x1000,
+ 0x98000: 0x80401000,
+ 0xa8000: 0x400000,
+ 0xb8000: 0x1040,
+ 0xc8000: 0x80000000,
+ 0xd8000: 0x400040,
+ 0xe8000: 0x401040,
+ 0xf8000: 0x80000040,
+ 0x100000: 0x400040,
+ 0x110000: 0x401000,
+ 0x120000: 0x80000040,
+ 0x130000: 0x0,
+ 0x140000: 0x1040,
+ 0x150000: 0x80400040,
+ 0x160000: 0x80401000,
+ 0x170000: 0x80001040,
+ 0x180000: 0x80401040,
+ 0x190000: 0x80000000,
+ 0x1a0000: 0x80400000,
+ 0x1b0000: 0x401040,
+ 0x1c0000: 0x80001000,
+ 0x1d0000: 0x400000,
+ 0x1e0000: 0x40,
+ 0x1f0000: 0x1000,
+ 0x108000: 0x80400000,
+ 0x118000: 0x80401040,
+ 0x128000: 0x0,
+ 0x138000: 0x401000,
+ 0x148000: 0x400040,
+ 0x158000: 0x80000000,
+ 0x168000: 0x80001040,
+ 0x178000: 0x40,
+ 0x188000: 0x80000040,
+ 0x198000: 0x1000,
+ 0x1a8000: 0x80001000,
+ 0x1b8000: 0x80400040,
+ 0x1c8000: 0x1040,
+ 0x1d8000: 0x80401000,
+ 0x1e8000: 0x400000,
+ 0x1f8000: 0x401040
+ },
+ {
+ 0x0: 0x80,
+ 0x1000: 0x1040000,
+ 0x2000: 0x40000,
+ 0x3000: 0x20000000,
+ 0x4000: 0x20040080,
+ 0x5000: 0x1000080,
+ 0x6000: 0x21000080,
+ 0x7000: 0x40080,
+ 0x8000: 0x1000000,
+ 0x9000: 0x20040000,
+ 0xa000: 0x20000080,
+ 0xb000: 0x21040080,
+ 0xc000: 0x21040000,
+ 0xd000: 0x0,
+ 0xe000: 0x1040080,
+ 0xf000: 0x21000000,
+ 0x800: 0x1040080,
+ 0x1800: 0x21000080,
+ 0x2800: 0x80,
+ 0x3800: 0x1040000,
+ 0x4800: 0x40000,
+ 0x5800: 0x20040080,
+ 0x6800: 0x21040000,
+ 0x7800: 0x20000000,
+ 0x8800: 0x20040000,
+ 0x9800: 0x0,
+ 0xa800: 0x21040080,
+ 0xb800: 0x1000080,
+ 0xc800: 0x20000080,
+ 0xd800: 0x21000000,
+ 0xe800: 0x1000000,
+ 0xf800: 0x40080,
+ 0x10000: 0x40000,
+ 0x11000: 0x80,
+ 0x12000: 0x20000000,
+ 0x13000: 0x21000080,
+ 0x14000: 0x1000080,
+ 0x15000: 0x21040000,
+ 0x16000: 0x20040080,
+ 0x17000: 0x1000000,
+ 0x18000: 0x21040080,
+ 0x19000: 0x21000000,
+ 0x1a000: 0x1040000,
+ 0x1b000: 0x20040000,
+ 0x1c000: 0x40080,
+ 0x1d000: 0x20000080,
+ 0x1e000: 0x0,
+ 0x1f000: 0x1040080,
+ 0x10800: 0x21000080,
+ 0x11800: 0x1000000,
+ 0x12800: 0x1040000,
+ 0x13800: 0x20040080,
+ 0x14800: 0x20000000,
+ 0x15800: 0x1040080,
+ 0x16800: 0x80,
+ 0x17800: 0x21040000,
+ 0x18800: 0x40080,
+ 0x19800: 0x21040080,
+ 0x1a800: 0x0,
+ 0x1b800: 0x21000000,
+ 0x1c800: 0x1000080,
+ 0x1d800: 0x40000,
+ 0x1e800: 0x20040000,
+ 0x1f800: 0x20000080
+ },
+ {
+ 0x0: 0x10000008,
+ 0x100: 0x2000,
+ 0x200: 0x10200000,
+ 0x300: 0x10202008,
+ 0x400: 0x10002000,
+ 0x500: 0x200000,
+ 0x600: 0x200008,
+ 0x700: 0x10000000,
+ 0x800: 0x0,
+ 0x900: 0x10002008,
+ 0xa00: 0x202000,
+ 0xb00: 0x8,
+ 0xc00: 0x10200008,
+ 0xd00: 0x202008,
+ 0xe00: 0x2008,
+ 0xf00: 0x10202000,
+ 0x80: 0x10200000,
+ 0x180: 0x10202008,
+ 0x280: 0x8,
+ 0x380: 0x200000,
+ 0x480: 0x202008,
+ 0x580: 0x10000008,
+ 0x680: 0x10002000,
+ 0x780: 0x2008,
+ 0x880: 0x200008,
+ 0x980: 0x2000,
+ 0xa80: 0x10002008,
+ 0xb80: 0x10200008,
+ 0xc80: 0x0,
+ 0xd80: 0x10202000,
+ 0xe80: 0x202000,
+ 0xf80: 0x10000000,
+ 0x1000: 0x10002000,
+ 0x1100: 0x10200008,
+ 0x1200: 0x10202008,
+ 0x1300: 0x2008,
+ 0x1400: 0x200000,
+ 0x1500: 0x10000000,
+ 0x1600: 0x10000008,
+ 0x1700: 0x202000,
+ 0x1800: 0x202008,
+ 0x1900: 0x0,
+ 0x1a00: 0x8,
+ 0x1b00: 0x10200000,
+ 0x1c00: 0x2000,
+ 0x1d00: 0x10002008,
+ 0x1e00: 0x10202000,
+ 0x1f00: 0x200008,
+ 0x1080: 0x8,
+ 0x1180: 0x202000,
+ 0x1280: 0x200000,
+ 0x1380: 0x10000008,
+ 0x1480: 0x10002000,
+ 0x1580: 0x2008,
+ 0x1680: 0x10202008,
+ 0x1780: 0x10200000,
+ 0x1880: 0x10202000,
+ 0x1980: 0x10200008,
+ 0x1a80: 0x2000,
+ 0x1b80: 0x202008,
+ 0x1c80: 0x200008,
+ 0x1d80: 0x0,
+ 0x1e80: 0x10000000,
+ 0x1f80: 0x10002008
+ },
+ {
+ 0x0: 0x100000,
+ 0x10: 0x2000401,
+ 0x20: 0x400,
+ 0x30: 0x100401,
+ 0x40: 0x2100401,
+ 0x50: 0x0,
+ 0x60: 0x1,
+ 0x70: 0x2100001,
+ 0x80: 0x2000400,
+ 0x90: 0x100001,
+ 0xa0: 0x2000001,
+ 0xb0: 0x2100400,
+ 0xc0: 0x2100000,
+ 0xd0: 0x401,
+ 0xe0: 0x100400,
+ 0xf0: 0x2000000,
+ 0x8: 0x2100001,
+ 0x18: 0x0,
+ 0x28: 0x2000401,
+ 0x38: 0x2100400,
+ 0x48: 0x100000,
+ 0x58: 0x2000001,
+ 0x68: 0x2000000,
+ 0x78: 0x401,
+ 0x88: 0x100401,
+ 0x98: 0x2000400,
+ 0xa8: 0x2100000,
+ 0xb8: 0x100001,
+ 0xc8: 0x400,
+ 0xd8: 0x2100401,
+ 0xe8: 0x1,
+ 0xf8: 0x100400,
+ 0x100: 0x2000000,
+ 0x110: 0x100000,
+ 0x120: 0x2000401,
+ 0x130: 0x2100001,
+ 0x140: 0x100001,
+ 0x150: 0x2000400,
+ 0x160: 0x2100400,
+ 0x170: 0x100401,
+ 0x180: 0x401,
+ 0x190: 0x2100401,
+ 0x1a0: 0x100400,
+ 0x1b0: 0x1,
+ 0x1c0: 0x0,
+ 0x1d0: 0x2100000,
+ 0x1e0: 0x2000001,
+ 0x1f0: 0x400,
+ 0x108: 0x100400,
+ 0x118: 0x2000401,
+ 0x128: 0x2100001,
+ 0x138: 0x1,
+ 0x148: 0x2000000,
+ 0x158: 0x100000,
+ 0x168: 0x401,
+ 0x178: 0x2100400,
+ 0x188: 0x2000001,
+ 0x198: 0x2100000,
+ 0x1a8: 0x0,
+ 0x1b8: 0x2100401,
+ 0x1c8: 0x100401,
+ 0x1d8: 0x400,
+ 0x1e8: 0x2000400,
+ 0x1f8: 0x100001
+ },
+ {
+ 0x0: 0x8000820,
+ 0x1: 0x20000,
+ 0x2: 0x8000000,
+ 0x3: 0x20,
+ 0x4: 0x20020,
+ 0x5: 0x8020820,
+ 0x6: 0x8020800,
+ 0x7: 0x800,
+ 0x8: 0x8020000,
+ 0x9: 0x8000800,
+ 0xa: 0x20800,
+ 0xb: 0x8020020,
+ 0xc: 0x820,
+ 0xd: 0x0,
+ 0xe: 0x8000020,
+ 0xf: 0x20820,
+ 0x80000000: 0x800,
+ 0x80000001: 0x8020820,
+ 0x80000002: 0x8000820,
+ 0x80000003: 0x8000000,
+ 0x80000004: 0x8020000,
+ 0x80000005: 0x20800,
+ 0x80000006: 0x20820,
+ 0x80000007: 0x20,
+ 0x80000008: 0x8000020,
+ 0x80000009: 0x820,
+ 0x8000000a: 0x20020,
+ 0x8000000b: 0x8020800,
+ 0x8000000c: 0x0,
+ 0x8000000d: 0x8020020,
+ 0x8000000e: 0x8000800,
+ 0x8000000f: 0x20000,
+ 0x10: 0x20820,
+ 0x11: 0x8020800,
+ 0x12: 0x20,
+ 0x13: 0x800,
+ 0x14: 0x8000800,
+ 0x15: 0x8000020,
+ 0x16: 0x8020020,
+ 0x17: 0x20000,
+ 0x18: 0x0,
+ 0x19: 0x20020,
+ 0x1a: 0x8020000,
+ 0x1b: 0x8000820,
+ 0x1c: 0x8020820,
+ 0x1d: 0x20800,
+ 0x1e: 0x820,
+ 0x1f: 0x8000000,
+ 0x80000010: 0x20000,
+ 0x80000011: 0x800,
+ 0x80000012: 0x8020020,
+ 0x80000013: 0x20820,
+ 0x80000014: 0x20,
+ 0x80000015: 0x8020000,
+ 0x80000016: 0x8000000,
+ 0x80000017: 0x8000820,
+ 0x80000018: 0x8020820,
+ 0x80000019: 0x8000020,
+ 0x8000001a: 0x8000800,
+ 0x8000001b: 0x0,
+ 0x8000001c: 0x20800,
+ 0x8000001d: 0x820,
+ 0x8000001e: 0x20020,
+ 0x8000001f: 0x8020800
+ }
+ ];
+
+ // Masks that select the SBOX input
+ var SBOX_MASK = [
+ 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
+ 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
+ ];
+
+ /**
+ * DES block cipher algorithm.
+ */
+ var DES = C_algo.DES = BlockCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var key = this._key;
+ var keyWords = key.words;
+
+ // Select 56 bits according to PC1
+ var keyBits = [];
+ for (var i = 0; i < 56; i++) {
+ var keyBitPos = PC1[i] - 1;
+ keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
+ }
+
+ // Assemble 16 subkeys
+ var subKeys = this._subKeys = [];
+ for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
+ // Create subkey
+ var subKey = subKeys[nSubKey] = [];
+
+ // Shortcut
+ var bitShift = BIT_SHIFTS[nSubKey];
+
+ // Select 48 bits according to PC2
+ for (var i = 0; i < 24; i++) {
+ // Select from the left 28 key bits
+ subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
+
+ // Select from the right 28 key bits
+ subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
+ }
+
+ // Since each subkey is applied to an expanded 32-bit input,
+ // the subkey can be broken into 8 values scaled to 32-bits,
+ // which allows the key to be used without expansion
+ subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
+ for (var i = 1; i < 7; i++) {
+ subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
+ }
+ subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
+ }
+
+ // Compute inverse subkeys
+ var invSubKeys = this._invSubKeys = [];
+ for (var i = 0; i < 16; i++) {
+ invSubKeys[i] = subKeys[15 - i];
+ }
+ },
+
+ encryptBlock: function (M, offset) {
+ this._doCryptBlock(M, offset, this._subKeys);
+ },
+
+ decryptBlock: function (M, offset) {
+ this._doCryptBlock(M, offset, this._invSubKeys);
+ },
+
+ _doCryptBlock: function (M, offset, subKeys) {
+ // Get input
+ this._lBlock = M[offset];
+ this._rBlock = M[offset + 1];
+
+ // Initial permutation
+ exchangeLR.call(this, 4, 0x0f0f0f0f);
+ exchangeLR.call(this, 16, 0x0000ffff);
+ exchangeRL.call(this, 2, 0x33333333);
+ exchangeRL.call(this, 8, 0x00ff00ff);
+ exchangeLR.call(this, 1, 0x55555555);
+
+ // Rounds
+ for (var round = 0; round < 16; round++) {
+ // Shortcuts
+ var subKey = subKeys[round];
+ var lBlock = this._lBlock;
+ var rBlock = this._rBlock;
+
+ // Feistel function
+ var f = 0;
+ for (var i = 0; i < 8; i++) {
+ f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
+ }
+ this._lBlock = rBlock;
+ this._rBlock = lBlock ^ f;
+ }
+
+ // Undo swap from last round
+ var t = this._lBlock;
+ this._lBlock = this._rBlock;
+ this._rBlock = t;
+
+ // Final permutation
+ exchangeLR.call(this, 1, 0x55555555);
+ exchangeRL.call(this, 8, 0x00ff00ff);
+ exchangeRL.call(this, 2, 0x33333333);
+ exchangeLR.call(this, 16, 0x0000ffff);
+ exchangeLR.call(this, 4, 0x0f0f0f0f);
+
+ // Set output
+ M[offset] = this._lBlock;
+ M[offset + 1] = this._rBlock;
+ },
+
+ keySize: 64/32,
+
+ ivSize: 64/32,
+
+ blockSize: 64/32
+ });
+
+ // Swap bits across the left and right words
+ function exchangeLR(offset, mask) {
+ var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
+ this._rBlock ^= t;
+ this._lBlock ^= t << offset;
+ }
+
+ function exchangeRL(offset, mask) {
+ var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
+ this._lBlock ^= t;
+ this._rBlock ^= t << offset;
+ }
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
+ */
+ C.DES = BlockCipher._createHelper(DES);
+
+ /**
+ * Triple-DES block cipher algorithm.
+ */
+ var TripleDES = C_algo.TripleDES = BlockCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var key = this._key;
+ var keyWords = key.words;
+
+ // Create DES instances
+ this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
+ this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
+ this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
+ },
+
+ encryptBlock: function (M, offset) {
+ this._des1.encryptBlock(M, offset);
+ this._des2.decryptBlock(M, offset);
+ this._des3.encryptBlock(M, offset);
+ },
+
+ decryptBlock: function (M, offset) {
+ this._des3.decryptBlock(M, offset);
+ this._des2.encryptBlock(M, offset);
+ this._des1.decryptBlock(M, offset);
+ },
+
+ keySize: 192/32,
+
+ ivSize: 64/32,
+
+ blockSize: 64/32
+ });
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
+ */
+ C.TripleDES = BlockCipher._createHelper(TripleDES);
+ }());
+
+
+ return CryptoJS.TripleDES;
+
+}));
+},{"./cipher-core":50,"./core":51,"./enc-base64":52,"./evpkdf":54,"./md5":59}],82:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@@ -7547,19 +12842,15 @@ module.exports = transfer;
return CryptoJS;
}));
-},{"./core":47}],50:[function(require,module,exports){
+},{"./core":51}],83:[function(require,module,exports){
/*! https://mths.be/utf8js v2.0.0 by @mathias */
;(function(root) {
- // Detect free variables 'exports'
var freeExports = typeof exports == 'object' && exports;
- // Detect free variable 'module'
var freeModule = typeof module == 'object' && module &&
module.exports == freeExports && module;
- // Detect free variable 'global', from Node.js or Browserified code,
- // and use it as 'root'
var freeGlobal = typeof global == 'object' && global;
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
root = freeGlobal;
@@ -7800,26 +13091,15 @@ module.exports = BigNumber; // jshint ignore:line
},{}],"web3":[function(require,module,exports){
-var web3 = require('./lib/web3');
-var namereg = require('./lib/web3/namereg');
-
-web3.providers.HttpProvider = require('./lib/web3/httpprovider');
-web3.providers.IpcProvider = require('./lib/web3/ipcprovider');
-
-web3.eth.contract = require('./lib/web3/contract');
-web3.eth.namereg = namereg.namereg;
-web3.eth.ibanNamereg = namereg.ibanNamereg;
-web3.eth.sendIBANTransaction = require('./lib/web3/transfer');
-web3.eth.iban = require('./lib/web3/iban');
+var Web3 = require('./lib/web3');
// dont override global variable
-if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
- window.web3 = web3;
+if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
+ window.Web3 = Web3;
}
-module.exports = web3;
-
+module.exports = Web3;
-},{"./lib/web3":22,"./lib/web3/contract":25,"./lib/web3/httpprovider":31,"./lib/web3/iban":32,"./lib/web3/ipcprovider":33,"./lib/web3/namereg":41,"./lib/web3/transfer":45}]},{},["web3"])
+},{"./lib/web3":22}]},{},["web3"])
//# sourceMappingURL=web3-light.js.map
`