Comparing version 3.1.3 to 3.2.0
@@ -0,1 +1,8 @@ | ||
v3.2.0 / 2015-08-29 | ||
================== | ||
* files reorganization | ||
* `iojs@3` test | ||
* Update `lodash`@3.10.1 | ||
v3.1.3 / 2015-07-14 | ||
@@ -2,0 +9,0 @@ ================== |
41
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
* @subpackage main | ||
* @version 3.0.0 | ||
* @version 3.2.0 | ||
* @author hex7c0 <hex7c0@gmail.com> | ||
@@ -16,4 +16,5 @@ * @copyright hex7c0 2014 | ||
*/ | ||
// load | ||
var min = __dirname + '/min/lib/'; | ||
var minNormal = min + 'normal/index.js'; | ||
var minLodash = min + 'lodash/index.js'; | ||
@@ -35,7 +36,37 @@ /* | ||
if (lodash) { | ||
return require(min + 'lodash/index.js')(algorithm, password); | ||
if (!lodash) { | ||
return require(minNormal)(algorithm, password); | ||
} | ||
return require(min + 'normal/index.js')(algorithm, password); | ||
return require(minLodash)(algorithm, password); | ||
} | ||
module.exports = arc4; | ||
/** | ||
* export normal function | ||
* | ||
* @exports normal | ||
* @function normal | ||
* @param {String} algorithm - user key | ||
* @param {String|Array|Buffer} password - user key | ||
* @return {Object} | ||
*/ | ||
function normal(algorithm, password) { | ||
return require(minNormal)(algorithm, password); | ||
} | ||
module.exports.normal = normal; | ||
/** | ||
* export normal function | ||
* | ||
* @exports normal | ||
* @function normal | ||
* @param {String} algorithm - user key | ||
* @param {String|Array|Buffer} password - user key | ||
* @return {Object} | ||
*/ | ||
function lodash(algorithm, password) { | ||
return require(minLodash)(algorithm, password); | ||
} | ||
module.exports.lodash = lodash; |
"use strict"; | ||
function arc4(algorithm, password, lodash) { | ||
return lodash ? require(min + "lodash/index.js")(algorithm, password) : require(min + "normal/index.js")(algorithm, password); | ||
return lodash ? require(minLodash)(algorithm, password) : require(minNormal)(algorithm, password); | ||
} | ||
var min = __dirname + "/min/lib/"; | ||
function normal(algorithm, password) { | ||
return require(minNormal)(algorithm, password); | ||
} | ||
module.exports = arc4; | ||
function lodash(algorithm, password) { | ||
return require(minLodash)(algorithm, password); | ||
} | ||
var min = __dirname + "/min/lib/", minNormal = min + "normal/index.js", minLodash = min + "lodash/index.js"; | ||
module.exports = arc4, module.exports.normal = normal, module.exports.lodash = lodash; |
@@ -50,3 +50,3 @@ 'use strict'; | ||
var len = _.size(key); | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -151,3 +151,3 @@ s[j] = [ s[i], s[i] = s[j] ][0]; | ||
out += String | ||
.fromCharCode(num.charCodeAt(0) ^ ksa[(ksa[i] + ksa[j]) % 256]); | ||
.fromCharCode(num.charCodeAt(0) ^ ksa[(ksa[i] + ksa[j]) % 256]); | ||
return; | ||
@@ -154,0 +154,0 @@ }); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
* @subpackage lodash | ||
* @version 3.0.0 | ||
* @version 3.2.0 | ||
* @author hex7c0 <hex7c0@gmail.com> | ||
@@ -16,3 +16,2 @@ * @copyright hex7c0 2014 | ||
*/ | ||
// load | ||
var min = __dirname + '/'; | ||
@@ -35,17 +34,6 @@ | ||
var Class; | ||
switch (algorithm) { | ||
case 'arc4': | ||
Class = require(min + 'arc4.js'); | ||
break; | ||
case 'rc4a': | ||
Class = require(min + 'rc4a.js'); | ||
break; | ||
case 'vmpc': | ||
Class = require(min + 'vmpc.js'); | ||
break; | ||
case 'rc4+': | ||
Class = require(min + 'rc4+.js'); | ||
break; | ||
default: | ||
throw new TypeError('algorithm required'); | ||
try { | ||
Class = require(min + algorithm + '.js'); | ||
} catch (e) { | ||
throw new TypeError('algorithm required'); | ||
} | ||
@@ -52,0 +40,0 @@ if (!password) { |
@@ -50,3 +50,3 @@ 'use strict'; | ||
var len = _.size(key); | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -53,0 +53,0 @@ s[j] = [ s[i], s[i] = s[j] ][0]; |
@@ -50,3 +50,3 @@ 'use strict'; | ||
var len = _.size(key); | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -162,3 +162,3 @@ s[j] = [ s[i], s[i] = s[j] ][0]; | ||
out += String | ||
.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256]); | ||
.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256]); | ||
} | ||
@@ -165,0 +165,0 @@ } |
@@ -50,3 +50,3 @@ 'use strict'; | ||
var len = _.size(key); | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -53,0 +53,0 @@ s[j] = [ s[i], s[i] = s[j] ][0]; |
@@ -49,3 +49,3 @@ 'use strict'; | ||
var len = key.length; | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -72,3 +72,3 @@ s[j] = [ s[i], s[i] = s[j] ][0]; | ||
var ksa = gksa.slice(); | ||
for (var y = 0; y < length; y++) { | ||
for (var y = 0; y < length; ++y) { | ||
i = (i + 1) % 256; | ||
@@ -124,3 +124,3 @@ j = (j + ksa[i]) % 256; | ||
var keys = new Buffer(key); | ||
for (var i = 0, ii = keys.length; i < ii; i++) { | ||
for (var i = 0, ii = keys.length; i < ii; ++i) { | ||
this.key[i] = keys[i]; | ||
@@ -148,3 +148,3 @@ } | ||
var ksa = this.ksa.slice(); | ||
for (var y = 0, l = str.length; y < l; y++) { | ||
for (var y = 0, l = str.length; y < l; ++y) { | ||
i = (i + 1) % 256; | ||
@@ -154,3 +154,3 @@ j = (j + ksa[i]) % 256; | ||
out += String | ||
.fromCharCode(str.charCodeAt(y) ^ ksa[(ksa[i] + ksa[j]) % 256]); | ||
.fromCharCode(str.charCodeAt(y) ^ ksa[(ksa[i] + ksa[j]) % 256]); | ||
} | ||
@@ -174,3 +174,3 @@ return out; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'hex'); | ||
.toString(output_encoding || 'hex'); | ||
}; | ||
@@ -192,3 +192,3 @@ | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'utf8'); | ||
.toString(output_encoding || 'utf8'); | ||
}; | ||
@@ -195,0 +195,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
* @subpackage normal | ||
* @version 3.0.0 | ||
* @version 3.2.0 | ||
* @author hex7c0 <hex7c0@gmail.com> | ||
@@ -16,3 +16,2 @@ * @copyright hex7c0 2014 | ||
*/ | ||
// load | ||
var min = __dirname + '/'; | ||
@@ -35,17 +34,6 @@ | ||
var Class; | ||
switch (algorithm) { | ||
case 'arc4': | ||
Class = require(min + 'arc4.js'); | ||
break; | ||
case 'rc4a': | ||
Class = require(min + 'rc4a.js'); | ||
break; | ||
case 'vmpc': | ||
Class = require(min + 'vmpc.js'); | ||
break; | ||
case 'rc4+': | ||
Class = require(min + 'rc4+.js'); | ||
break; | ||
default: | ||
throw new TypeError('algorithm required'); | ||
try { | ||
Class = require(min + algorithm + '.js'); | ||
} catch (e) { | ||
throw new TypeError('algorithm required'); | ||
} | ||
@@ -52,0 +40,0 @@ if (!password) { |
@@ -49,3 +49,3 @@ 'use strict'; | ||
var len = key.length; | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -73,3 +73,3 @@ s[j] = [ s[i], s[i] = s[j] ][0]; | ||
var ksa = gksa.slice(); | ||
for (var y = 0; y < length; y++) { | ||
for (var y = 0; y < length; ++y) { | ||
i = (i + 1) % 256; | ||
@@ -128,3 +128,3 @@ a = ksa[i]; | ||
var keys = new Buffer(key); | ||
for (var i = 0, ii = keys.length; i < ii; i++) { | ||
for (var i = 0, ii = keys.length; i < ii; ++i) { | ||
this.key[i] = keys[i]; | ||
@@ -153,3 +153,3 @@ } | ||
var ksa = this.ksa.slice(); | ||
for (var y = 0, l = str.length; y < l; y++) { | ||
for (var y = 0, l = str.length; y < l; ++y) { | ||
i = (i + 1) % 256; | ||
@@ -181,3 +181,3 @@ a = ksa[i]; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'hex'); | ||
.toString(output_encoding || 'hex'); | ||
}; | ||
@@ -199,3 +199,3 @@ | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'utf8'); | ||
.toString(output_encoding || 'utf8'); | ||
}; | ||
@@ -202,0 +202,0 @@ |
@@ -49,3 +49,3 @@ 'use strict'; | ||
var len = key.length; | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -73,3 +73,3 @@ s[j] = [ s[i], s[i] = s[j] ][0]; | ||
var s2 = gksa.slice(); | ||
for (var y = 0; y < length; y++) { | ||
for (var y = 0; y < length; ++y) { | ||
i = (i + 1) % 256; | ||
@@ -130,3 +130,3 @@ j1 = (j1 + s1[i]) % 256; | ||
var keys = new Buffer(key); | ||
for (var i = 0, ii = keys.length; i < ii; i++) { | ||
for (var i = 0, ii = keys.length; i < ii; ++i) { | ||
this.key[i] = keys[i]; | ||
@@ -155,3 +155,3 @@ } | ||
var s2 = this.ksa.slice(); | ||
for (var y = 0, l = str.length; y < l; y++) { | ||
for (var y = 0, l = str.length; y < l; ++y) { | ||
i = (i + 1) % 256; | ||
@@ -165,3 +165,3 @@ j1 = (j1 + s1[i]) % 256; | ||
out += String | ||
.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256]); | ||
.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256]); | ||
} | ||
@@ -186,3 +186,3 @@ } | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'hex'); | ||
.toString(output_encoding || 'hex'); | ||
}; | ||
@@ -204,3 +204,3 @@ | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'utf8'); | ||
.toString(output_encoding || 'utf8'); | ||
}; | ||
@@ -207,0 +207,0 @@ |
@@ -49,3 +49,3 @@ 'use strict'; | ||
var len = key.length; | ||
for (var i = 0; i < 256; i++) { | ||
for (var i = 0; i < 256; ++i) { | ||
j = (j + s[i] + key[i % len]) % 256; | ||
@@ -73,3 +73,3 @@ s[j] = [ s[i], s[i] = s[j] ][0]; | ||
var ksa = gksa.slice(); | ||
for (var y = 0; y < length; y++) { | ||
for (var y = 0; y < length; ++y) { | ||
a = ksa[i]; | ||
@@ -127,3 +127,3 @@ j = ksa[(j + a) % 256]; | ||
var keys = new Buffer(key); | ||
for (var i = 0, ii = keys.length; i < ii; i++) { | ||
for (var i = 0, ii = keys.length; i < ii; ++i) { | ||
this.key[i] = keys[i]; | ||
@@ -152,3 +152,3 @@ } | ||
var ksa = this.ksa.slice(); | ||
for (var y = 0, l = str.length; y < l; y++) { | ||
for (var y = 0, l = str.length; y < l; ++y) { | ||
a = ksa[i]; | ||
@@ -178,3 +178,3 @@ j = ksa[(j + a) % 256]; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'hex'); | ||
.toString(output_encoding || 'hex'); | ||
}; | ||
@@ -196,3 +196,3 @@ | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
.toString(output_encoding || 'utf8'); | ||
.toString(output_encoding || 'utf8'); | ||
}; | ||
@@ -199,0 +199,0 @@ |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -6,0 +6,0 @@ return s; |
@@ -5,20 +5,5 @@ "use strict"; | ||
var Class; | ||
switch (algorithm) { | ||
case "arc4": | ||
Class = require(min + "arc4.js"); | ||
break; | ||
case "rc4a": | ||
Class = require(min + "rc4a.js"); | ||
break; | ||
case "vmpc": | ||
Class = require(min + "vmpc.js"); | ||
break; | ||
case "rc4+": | ||
Class = require(min + "rc4+.js"); | ||
break; | ||
default: | ||
try { | ||
Class = require(min + algorithm + ".js"); | ||
} catch (e) { | ||
throw new TypeError("algorithm required"); | ||
@@ -25,0 +10,0 @@ } |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -6,0 +6,0 @@ return s; |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -6,0 +6,0 @@ return s; |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = _.size(key), i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -6,0 +6,0 @@ return s; |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -10,3 +10,3 @@ return s; | ||
function body(inp, gksa, container, length) { | ||
for (var i = 0, j = 0, out = container, ksa = gksa.slice(), y = 0; length > y; y++) i = (i + 1) % 256, | ||
for (var i = 0, j = 0, out = container, ksa = gksa.slice(), y = 0; length > y; ++y) i = (i + 1) % 256, | ||
j = (j + ksa[i]) % 256, ksa[j] = [ ksa[i], ksa[i] = ksa[j] ][0], out[y] = inp[y] ^ ksa[(ksa[i] + ksa[j]) % 256]; | ||
@@ -28,7 +28,7 @@ return out; | ||
this.key = new Array(key.legth); | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; i++) this.key[i] = keys[i]; | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; ++i) this.key[i] = keys[i]; | ||
} | ||
this.ksa = gKsa(this.key); | ||
}, Arc4.prototype.codeString = deprecate(function(str) { | ||
for (var i = 0, j = 0, out = "", ksa = this.ksa.slice(), y = 0, l = str.length; l > y; y++) i = (i + 1) % 256, | ||
for (var i = 0, j = 0, out = "", ksa = this.ksa.slice(), y = 0, l = str.length; l > y; ++y) i = (i + 1) % 256, | ||
j = (j + ksa[i]) % 256, ksa[j] = [ ksa[i], ksa[i] = ksa[j] ][0], out += String.fromCharCode(str.charCodeAt(y) ^ ksa[(ksa[i] + ksa[j]) % 256]); | ||
@@ -35,0 +35,0 @@ return out; |
@@ -5,20 +5,5 @@ "use strict"; | ||
var Class; | ||
switch (algorithm) { | ||
case "arc4": | ||
Class = require(min + "arc4.js"); | ||
break; | ||
case "rc4a": | ||
Class = require(min + "rc4a.js"); | ||
break; | ||
case "vmpc": | ||
Class = require(min + "vmpc.js"); | ||
break; | ||
case "rc4+": | ||
Class = require(min + "rc4+.js"); | ||
break; | ||
default: | ||
try { | ||
Class = require(min + algorithm + ".js"); | ||
} catch (e) { | ||
throw new TypeError("algorithm required"); | ||
@@ -25,0 +10,0 @@ } |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -10,3 +10,3 @@ return s; | ||
function body(inp, gksa, container, length) { | ||
for (var a, b, c, i = 0, j = 0, out = container, ksa = gksa.slice(), y = 0; length > y; y++) i = (i + 1) % 256, | ||
for (var a, b, c, i = 0, j = 0, out = container, ksa = gksa.slice(), y = 0; length > y; ++y) i = (i + 1) % 256, | ||
a = ksa[i], j = ksa[(j + a) % 256], b = ksa[j], ksa[j] = [ a, ksa[i] = b ][0], c = (ksa[i << 5 ^ j >> 3] + ksa[j << 5 ^ i >> 3]) % 256, | ||
@@ -28,7 +28,7 @@ out[y] = inp[y] ^ ksa[a + b] + ksa[170 ^ c] ^ ksa[j + b]; | ||
if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; i++) this.key[i] = keys[i]; | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; ++i) this.key[i] = keys[i]; | ||
} | ||
this.ksa = gKsa(this.key); | ||
}, Rc4p.prototype.codeString = deprecate(function(str) { | ||
for (var a, b, c, i = 0, j = 0, out = "", ksa = this.ksa.slice(), y = 0, l = str.length; l > y; y++) i = (i + 1) % 256, | ||
for (var a, b, c, i = 0, j = 0, out = "", ksa = this.ksa.slice(), y = 0, l = str.length; l > y; ++y) i = (i + 1) % 256, | ||
a = ksa[i], j = ksa[(j + a) % 256], b = ksa[j], ksa[j] = [ a, ksa[i] = b ][0], c = (ksa[i << 5 ^ j >> 3] + ksa[j << 5 ^ i >> 3]) % 256, | ||
@@ -35,0 +35,0 @@ out += String.fromCharCode(str.charCodeAt(y) ^ ksa[a + b] + ksa[170 ^ c] ^ ksa[j + b]); |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -10,3 +10,3 @@ return s; | ||
function body(inp, gksa, container, length) { | ||
for (var i = 0, j1 = 0, j2 = 0, out = container, s1 = gksa.slice(), s2 = gksa.slice(), y = 0; length > y; y++) i = (i + 1) % 256, | ||
for (var i = 0, j1 = 0, j2 = 0, out = container, s1 = gksa.slice(), s2 = gksa.slice(), y = 0; length > y; ++y) i = (i + 1) % 256, | ||
j1 = (j1 + s1[i]) % 256, s1[j1] = [ s1[i], s1[i] = s1[j1] ][0], out[y] = inp[y] ^ s2[(s1[i] + s1[j1]) % 256], | ||
@@ -29,7 +29,7 @@ ++y < length && (j2 = (j2 + s2[i]) % 256, s2[j2] = [ s2[i], s2[i] = s2[j2] ][0], | ||
if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; i++) this.key[i] = keys[i]; | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; ++i) this.key[i] = keys[i]; | ||
} | ||
this.ksa = gKsa(this.key); | ||
}, Rc4a.prototype.codeString = deprecate(function(str) { | ||
for (var i = 0, j1 = 0, j2 = 0, out = "", s1 = this.ksa.slice(), s2 = this.ksa.slice(), y = 0, l = str.length; l > y; y++) i = (i + 1) % 256, | ||
for (var i = 0, j1 = 0, j2 = 0, out = "", s1 = this.ksa.slice(), s2 = this.ksa.slice(), y = 0, l = str.length; l > y; ++y) i = (i + 1) % 256, | ||
j1 = (j1 + s1[i]) % 256, s1[j1] = [ s1[i], s1[i] = s1[j1] ][0], out += String.fromCharCode(str.charCodeAt(y) ^ s2[(s1[i] + s1[j1]) % 256]), | ||
@@ -36,0 +36,0 @@ ++y < l && (j2 = (j2 + s2[i]) % 256, s2[j2] = [ s2[i], s2[i] = s2[j2] ][0], out += String.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256])); |
"use strict"; | ||
function gKsa(key) { | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; i++) j = (j + s[i] + key[i % len]) % 256, | ||
for (var j = 0, s = box.slice(), len = key.length, i = 0; 256 > i; ++i) j = (j + s[i] + key[i % len]) % 256, | ||
s[j] = [ s[i], s[i] = s[j] ][0]; | ||
@@ -10,3 +10,3 @@ return s; | ||
function body(inp, gksa, container, length) { | ||
for (var a, b, i = 0, j = 0, out = container, ksa = gksa.slice(), y = 0; length > y; y++) a = ksa[i], | ||
for (var a, b, i = 0, j = 0, out = container, ksa = gksa.slice(), y = 0; length > y; ++y) a = ksa[i], | ||
j = ksa[(j + a) % 256], b = ksa[j], out[y] = inp[y] ^ ksa[ksa[b] + 1], ksa[j] = [ a, ksa[i] = b ][0], | ||
@@ -28,7 +28,7 @@ i = (i + 1) % 256; | ||
if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; i++) this.key[i] = keys[i]; | ||
for (var keys = new Buffer(key), i = 0, ii = keys.length; ii > i; ++i) this.key[i] = keys[i]; | ||
} | ||
this.ksa = gKsa(this.key); | ||
}, Vmpc.prototype.codeString = deprecate(function(str) { | ||
for (var a, b, i = 0, j = 0, out = "", ksa = this.ksa.slice(), y = 0, l = str.length; l > y; y++) a = ksa[i], | ||
for (var a, b, i = 0, j = 0, out = "", ksa = this.ksa.slice(), y = 0, l = str.length; l > y; ++y) a = ksa[i], | ||
j = ksa[(j + a) % 256], b = ksa[j], out += String.fromCharCode(str.charCodeAt(y) ^ ksa[ksa[b] + 1]), | ||
@@ -35,0 +35,0 @@ ksa[j] = [ a, ksa[i] = b ][0], i = (i + 1) % 256; |
{ | ||
"version": "3.1.3", | ||
"version": "3.2.0", | ||
"name": "arc4", | ||
@@ -30,3 +30,3 @@ "description": "rc4 stream cipher", | ||
"dependencies": { | ||
"lodash": "3.10.0" | ||
"lodash": "3.10.1" | ||
}, | ||
@@ -38,3 +38,3 @@ "devDependencies": { | ||
"grunt-contrib-jshint": "~0.11", | ||
"grunt-endline": "~0.2", | ||
"grunt-endline": "~0.3", | ||
"istanbul": "~0.3", | ||
@@ -41,0 +41,0 @@ "mocha": "~2.2" |
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
131201
12
2533
1
+ Addedlodash@3.10.1(transitive)
- Removedlodash@3.10.0(transitive)
Updatedlodash@3.10.1