Comparing version 3.3.8 to 3.4.0
@@ -0,1 +1,7 @@ | ||
v3.4.0 / 2017-12-31 | ||
================== | ||
* RC4A: fix S2 shouldn't be duplicate of S1 (@bryc) | ||
* Tested against `node`@9 | ||
v3.3.8 / 2017-05-28 | ||
@@ -2,0 +8,0 @@ ================== |
"use strict"; | ||
var min = __dirname + "/min/lib/", minNormal = min + "normal/index.js", minLodash = min + "lodash/index.js"; | ||
function arc4(algorithm, password, lodash) { | ||
@@ -7,2 +9,4 @@ return lodash ? require(minLodash)(algorithm, password) : require(minNormal)(algorithm, password); | ||
module.exports = arc4; | ||
function normal(algorithm, password) { | ||
@@ -12,2 +16,4 @@ return require(minNormal)(algorithm, password); | ||
module.exports.normal = normal; | ||
function lodash(algorithm, password) { | ||
@@ -17,4 +23,2 @@ 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; | ||
module.exports.lodash = lodash; |
@@ -39,3 +39,3 @@ 'use strict'; | ||
/** | ||
* generate ksa | ||
* Generate KSA. | ||
* | ||
@@ -59,15 +59,40 @@ * @function gKsa | ||
/** | ||
* body cipher | ||
* Generate PRGA. | ||
* | ||
* @function gPrga | ||
* @param {Array} key - user key | ||
* @param {Array} s - s1 vector | ||
* @return {Array} | ||
*/ | ||
function gPrga(key, s) { | ||
var keystream = []; | ||
var k = 0; | ||
var j = 0; | ||
var len = _.size(key); | ||
for (var i = 0; i < len; ++i) { | ||
k = (k + 1) % 256; | ||
j = (j + s[k]) % 256; | ||
s[j] = [ s[k], s[k] = s[j] ][0]; | ||
keystream[i] = s[(s[k] + s[j]) % 256]; | ||
} | ||
return keystream; | ||
} | ||
/** | ||
* Body cipher. | ||
* | ||
* @function body | ||
* @param {Array|Buffer} inp - input | ||
* @param {Array} gksa - ksa box | ||
* @param {Array} ksa - ksa box | ||
* @param {Array} prga - prga box | ||
* @return {Array|Buffer} | ||
*/ | ||
function body(inp, gksa) { | ||
function body(inp, ksa, prga) { | ||
var i = 0, j1 = 0, j2 = 0; | ||
var s1 = gksa.slice(); | ||
var s2 = gksa.slice(); | ||
var out = []; | ||
var s1 = ksa.slice(); | ||
var s2 = prga.slice(); | ||
for (var y = 0, l = _.size(inp); y < l; y++) { | ||
@@ -84,2 +109,3 @@ i = (i + 1) % 256; | ||
} | ||
return out; | ||
@@ -114,3 +140,5 @@ } | ||
this.key = null; | ||
this.derivatedKey = null; | ||
this.ksa = null; | ||
this.prga = null; | ||
this.change(key); | ||
@@ -139,2 +167,4 @@ } | ||
this.ksa = gKsa(this.key); | ||
this.derivatedKey = gPrga(this.key, this.ksa); | ||
this.prga = gKsa(this.derivatedKey); | ||
return; | ||
@@ -155,3 +185,3 @@ }; | ||
var s1 = this.ksa.slice(); | ||
var s2 = this.ksa.slice(); | ||
var s2 = this.prga.slice(); | ||
var out = ''; | ||
@@ -185,3 +215,4 @@ for (var y = 0, l = _.size(str); y < l; y++) { | ||
var out = new Buffer(str, input_encoding || 'utf8'); | ||
return new Buffer(body(out, this.ksa)).toString(output_encoding || 'hex'); | ||
return new Buffer(body(out, this.ksa, this.prga)).toString(output_encoding | ||
|| 'hex'); | ||
}; | ||
@@ -201,3 +232,4 @@ | ||
var out = new Buffer(str, input_encoding || 'hex'); | ||
return new Buffer(body(out, this.ksa)).toString(output_encoding || 'utf8'); | ||
return new Buffer(body(out, this.ksa, this.prga)).toString(output_encoding | ||
|| 'utf8'); | ||
}; | ||
@@ -216,3 +248,3 @@ | ||
return body(arr, this.ksa); | ||
return body(arr, this.ksa, this.prga); | ||
}; | ||
@@ -231,3 +263,3 @@ | ||
return new Buffer(body(buff, this.ksa)); | ||
return new Buffer(body(buff, this.ksa, this.prga)); | ||
}; | ||
@@ -234,0 +266,0 @@ |
@@ -38,3 +38,3 @@ 'use strict'; | ||
/** | ||
* generate ksa | ||
* Generate KSA. | ||
* | ||
@@ -54,2 +54,3 @@ * @function gKsa | ||
} | ||
return s; | ||
@@ -59,7 +60,32 @@ } | ||
/** | ||
* body cipher | ||
* Generate PRGA. | ||
* | ||
* @function gPrga | ||
* @param {Array} key - user key | ||
* @param {Array} s - s1 vector | ||
* @return {Array} | ||
*/ | ||
function gPrga(key, s) { | ||
var keystream = []; | ||
var k = 0; | ||
var j = 0; | ||
var len = key.length; | ||
for (var i = 0; i < len; ++i) { | ||
k = (k + 1) % 256; | ||
j = (j + s[k]) % 256; | ||
s[j] = [ s[k], s[k] = s[j] ][0]; | ||
keystream[i] = s[(s[k] + s[j]) % 256]; | ||
} | ||
return keystream; | ||
} | ||
/** | ||
* Body cipher. | ||
* | ||
* @function body | ||
* @param {Array|Buffer} inp - input | ||
* @param {Array} gksa - ksa box | ||
* @param {Array} ksa - ksa box | ||
* @param {Array} prga - prga box | ||
* @param {Array|Buffer} container - out container | ||
@@ -69,8 +95,8 @@ * @param {Integer} length - limit | ||
*/ | ||
function body(inp, gksa, container, length) { | ||
function body(inp, ksa, prga, container, length) { | ||
var i = 0, j1 = 0, j2 = 0; | ||
var out = container; | ||
var s1 = gksa.slice(); | ||
var s2 = gksa.slice(); | ||
var s1 = ksa.slice(); | ||
var s2 = prga.slice(); | ||
for (var y = 0; y < length; ++y) { | ||
@@ -87,2 +113,3 @@ i = (i + 1) % 256; | ||
} | ||
return out; | ||
@@ -116,3 +143,5 @@ } | ||
this.key = null; | ||
this.derivatedKey = null; | ||
this.ksa = null; | ||
this.prga = null; | ||
this.change(key); | ||
@@ -141,2 +170,4 @@ } | ||
this.ksa = gKsa(this.key); | ||
this.derivatedKey = gPrga(this.key, this.ksa); | ||
this.prga = gKsa(this.derivatedKey); | ||
return; | ||
@@ -158,3 +189,3 @@ }; | ||
var s1 = this.ksa.slice(); | ||
var s2 = this.ksa.slice(); | ||
var s2 = this.prga.slice(); | ||
for (var y = 0, l = str.length; y < l; ++y) { | ||
@@ -188,3 +219,3 @@ i = (i + 1) % 256; | ||
var l = out.length; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
return new Buffer(body(out, this.ksa, this.prga, new Buffer(l), l)) | ||
.toString(output_encoding || 'hex'); | ||
@@ -206,3 +237,3 @@ }; | ||
var l = out.length; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)) | ||
return new Buffer(body(out, this.ksa, this.prga, new Buffer(l), l)) | ||
.toString(output_encoding || 'utf8'); | ||
@@ -223,3 +254,3 @@ }; | ||
var l = arr.length; | ||
return body(arr, this.ksa, new Array(l), l); | ||
return body(arr, this.ksa, this.prga, new Array(l), l); | ||
}; | ||
@@ -239,3 +270,3 @@ | ||
var l = buff.length; | ||
return body(buff, this.ksa, new Buffer(l), l); | ||
return body(buff, this.ksa, this.prga, new Buffer(l), l); | ||
}; | ||
@@ -242,0 +273,0 @@ |
"use strict"; | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -11,3 +13,3 @@ for (var j = 0, s = box.slice(), len = _.size(key), i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
return _.map(inp, function(num) { | ||
return i = (i + 1) % 256, j = (j + ksa[i]) % 256, ksa[j] = [ ksa[i], ksa[i] = ksa[j] ][0], | ||
return j = (j + ksa[i = (i + 1) % 256]) % 256, ksa[j] = [ ksa[i], ksa[i] = ksa[j] ][0], | ||
num ^ ksa[(ksa[i] + ksa[j]) % 256]; | ||
@@ -17,2 +19,6 @@ }); | ||
module.exports = function(password) { | ||
return new Arc4(password); | ||
}; | ||
function Arc4(key) { | ||
@@ -22,7 +28,3 @@ this.key = null, this.ksa = null, this.change(key); | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Arc4(password); | ||
}, Arc4.prototype.change = function(key) { | ||
Arc4.prototype.change = function(key) { | ||
if (_.isArray(key)) this.key = key; else { | ||
@@ -29,0 +31,0 @@ if (!_.isString(key) && !Buffer.isBuffer(key)) throw new Error("Invalid data"); |
"use strict"; | ||
var min = __dirname + "/"; | ||
function lodash(algorithm, password) { | ||
@@ -14,4 +16,2 @@ var Class; | ||
var min = __dirname + "/"; | ||
module.exports = lodash; |
"use strict"; | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -11,3 +13,3 @@ for (var j = 0, s = box.slice(), len = _.size(key), i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
return _.map(inp, function(num) { | ||
return i = (i + 1) % 256, a = ksa[i], j = ksa[(j + a) % 256], b = ksa[j], ksa[j] = [ a, ksa[i] = b ][0], | ||
return a = ksa[i = (i + 1) % 256], j = ksa[(j + a) % 256], b = ksa[j], ksa[j] = [ a, ksa[i] = b ][0], | ||
num ^ ksa[a + b] + ksa[170] ^ ksa[j + b]; | ||
@@ -17,2 +19,6 @@ }); | ||
module.exports = function(password) { | ||
return new Rc4p(password); | ||
}; | ||
function Rc4p(key) { | ||
@@ -22,7 +28,3 @@ this.key = null, this.ksa = null, this.change(key); | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Rc4p(password); | ||
}, Rc4p.prototype.change = function(key) { | ||
Rc4p.prototype.change = function(key) { | ||
if (_.isArray(key)) this.key = key; else { | ||
@@ -29,0 +31,0 @@ if (!_.isString(key) && !Buffer.isBuffer(key)) throw new Error("Invalid data"); |
"use strict"; | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -8,4 +10,10 @@ for (var j = 0, s = box.slice(), len = _.size(key), i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
function body(inp, gksa) { | ||
for (var i = 0, j1 = 0, j2 = 0, s1 = gksa.slice(), s2 = gksa.slice(), out = [], y = 0, l = _.size(inp); y < l; y++) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
function gPrga(key, s) { | ||
for (var keystream = [], k = 0, j = 0, len = _.size(key), i = 0; i < len; ++i) s[j = (j + s[k = (k + 1) % 256]) % 256] = [ s[k], s[k] = s[j] ][0], | ||
keystream[i] = s[(s[k] + s[j]) % 256]; | ||
return keystream; | ||
} | ||
function body(inp, ksa, prga) { | ||
for (var i = 0, j1 = 0, j2 = 0, out = [], s1 = ksa.slice(), s2 = prga.slice(), y = 0, l = _.size(inp); y < l; y++) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
out.push(inp[y] ^ s2[(s1[i] + s1[j1]) % 256]), ++y < l && (s2[j2 = (j2 + s2[i]) % 256] = [ s2[i], s2[i] = s2[j2] ][0], | ||
@@ -16,11 +24,11 @@ out.push(inp[y] ^ s1[(s2[i] + s2[j1]) % 256])); | ||
module.exports = function(password) { | ||
return new Rc4a(password); | ||
}; | ||
function Rc4a(key) { | ||
this.key = null, this.ksa = null, this.change(key); | ||
this.key = null, this.derivatedKey = null, this.ksa = null, this.prga = null, this.change(key); | ||
} | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Rc4a(password); | ||
}, Rc4a.prototype.change = function(key) { | ||
Rc4a.prototype.change = function(key) { | ||
if (_.isArray(key)) this.key = key; else { | ||
@@ -32,5 +40,5 @@ if (!_.isString(key) && !Buffer.isBuffer(key)) throw new Error("Invalid data"); | ||
} | ||
this.ksa = gKsa(this.key); | ||
this.ksa = gKsa(this.key), this.derivatedKey = gPrga(this.key, this.ksa), this.prga = gKsa(this.derivatedKey); | ||
}, Rc4a.prototype.codeString = deprecate(function(str) { | ||
for (var i = 0, j1 = 0, j2 = 0, s1 = this.ksa.slice(), s2 = this.ksa.slice(), out = "", y = 0, l = _.size(str); y < l; y++) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
for (var i = 0, j1 = 0, j2 = 0, s1 = this.ksa.slice(), s2 = this.prga.slice(), out = "", y = 0, l = _.size(str); y < l; y++) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
out += String.fromCharCode(str.charCodeAt(y) ^ s2[(s1[i] + s1[j1]) % 256]), ++y < l && (s2[j2 = (j2 + s2[i]) % 256] = [ s2[i], s2[i] = s2[j2] ][0], | ||
@@ -41,10 +49,10 @@ out += String.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256])); | ||
var out = new Buffer(str, input_encoding || "utf8"); | ||
return new Buffer(body(out, this.ksa)).toString(output_encoding || "hex"); | ||
return new Buffer(body(out, this.ksa, this.prga)).toString(output_encoding || "hex"); | ||
}, Rc4a.prototype.decodeString = function(str, input_encoding, output_encoding) { | ||
var out = new Buffer(str, input_encoding || "hex"); | ||
return new Buffer(body(out, this.ksa)).toString(output_encoding || "utf8"); | ||
return new Buffer(body(out, this.ksa, this.prga)).toString(output_encoding || "utf8"); | ||
}, Rc4a.prototype.encodeArray = Rc4a.prototype.decodeArray = function(arr) { | ||
return body(arr, this.ksa); | ||
return body(arr, this.ksa, this.prga); | ||
}, Rc4a.prototype.encodeBuffer = Rc4a.prototype.decodeBuffer = function(buff) { | ||
return new Buffer(body(buff, this.ksa)); | ||
return new Buffer(body(buff, this.ksa, this.prga)); | ||
}, Rc4a.prototype.encode = function(boh, input_encoding, output_encoding) { | ||
@@ -51,0 +59,0 @@ if (_.isString(boh)) return this.encodeString(boh, input_encoding, output_encoding); |
"use strict"; | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -16,2 +18,6 @@ for (var j = 0, s = box.slice(), len = _.size(key), i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
module.exports = function(password) { | ||
return new Vmpc(password); | ||
}; | ||
function Vmpc(key) { | ||
@@ -21,7 +27,3 @@ this.key = null, this.ksa = null, this.change(key); | ||
var deprecate = require("util").deprecate, _ = require("lodash"), box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Vmpc(password); | ||
}, Vmpc.prototype.change = function(key) { | ||
Vmpc.prototype.change = function(key) { | ||
if (_.isArray(key)) this.key = key; else { | ||
@@ -28,0 +30,0 @@ if (!_.isString(key) && !Buffer.isBuffer(key)) throw new Error("Invalid data"); |
"use strict"; | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -14,2 +16,6 @@ for (var j = 0, s = box.slice(), len = key.length, i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
module.exports = function(password) { | ||
return new Arc4(password); | ||
}; | ||
function Arc4(key) { | ||
@@ -19,7 +25,3 @@ this.key = null, this.ksa = null, this.change(key); | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Arc4(password); | ||
}, Arc4.prototype.change = function(key) { | ||
Arc4.prototype.change = function(key) { | ||
if (Array.isArray(key)) this.key = key; else { | ||
@@ -26,0 +28,0 @@ if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); |
"use strict"; | ||
var min = __dirname + "/"; | ||
function normal(algorithm, password) { | ||
@@ -14,4 +16,2 @@ var Class; | ||
var min = __dirname + "/"; | ||
module.exports = normal; |
"use strict"; | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -15,2 +17,6 @@ for (var j = 0, s = box.slice(), len = key.length, i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
module.exports = function(password) { | ||
return new Rc4p(password); | ||
}; | ||
function Rc4p(key) { | ||
@@ -20,7 +26,3 @@ this.key = null, this.ksa = null, this.change(key); | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Rc4p(password); | ||
}, Rc4p.prototype.change = function(key) { | ||
Rc4p.prototype.change = function(key) { | ||
if (this.key = new Array(key.length), Array.isArray(key)) this.key = key; else { | ||
@@ -27,0 +29,0 @@ if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); |
"use strict"; | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -8,4 +10,10 @@ for (var j = 0, s = box.slice(), len = key.length, i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
function body(inp, gksa, container, length) { | ||
for (var i = 0, j1 = 0, j2 = 0, out = container, s1 = gksa.slice(), s2 = gksa.slice(), y = 0; y < length; ++y) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
function gPrga(key, s) { | ||
for (var keystream = [], k = 0, j = 0, len = key.length, i = 0; i < len; ++i) s[j = (j + s[k = (k + 1) % 256]) % 256] = [ s[k], s[k] = s[j] ][0], | ||
keystream[i] = s[(s[k] + s[j]) % 256]; | ||
return keystream; | ||
} | ||
function body(inp, ksa, prga, container, length) { | ||
for (var i = 0, j1 = 0, j2 = 0, out = container, s1 = ksa.slice(), s2 = prga.slice(), y = 0; y < length; ++y) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
out[y] = inp[y] ^ s2[(s1[i] + s1[j1]) % 256], ++y < length && (s2[j2 = (j2 + s2[i]) % 256] = [ s2[i], s2[i] = s2[j2] ][0], | ||
@@ -16,11 +24,11 @@ out[y] = inp[y] ^ s1[(s2[i] + s2[j1]) % 256]); | ||
module.exports = function(password) { | ||
return new Rc4a(password); | ||
}; | ||
function Rc4a(key) { | ||
this.key = null, this.ksa = null, this.change(key); | ||
this.key = null, this.derivatedKey = null, this.ksa = null, this.prga = null, this.change(key); | ||
} | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Rc4a(password); | ||
}, Rc4a.prototype.change = function(key) { | ||
Rc4a.prototype.change = function(key) { | ||
if (this.key = new Array(key.length), Array.isArray(key)) this.key = key; else { | ||
@@ -30,5 +38,5 @@ if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); | ||
} | ||
this.ksa = gKsa(this.key); | ||
this.ksa = gKsa(this.key), this.derivatedKey = gPrga(this.key, this.ksa), this.prga = gKsa(this.derivatedKey); | ||
}, 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; y < l; ++y) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
for (var i = 0, j1 = 0, j2 = 0, out = "", s1 = this.ksa.slice(), s2 = this.prga.slice(), y = 0, l = str.length; y < l; ++y) s1[j1 = (j1 + s1[i = (i + 1) % 256]) % 256] = [ s1[i], s1[i] = s1[j1] ][0], | ||
out += String.fromCharCode(str.charCodeAt(y) ^ s2[(s1[i] + s1[j1]) % 256]), ++y < l && (s2[j2 = (j2 + s2[i]) % 256] = [ s2[i], s2[i] = s2[j2] ][0], | ||
@@ -39,12 +47,12 @@ out += String.fromCharCode(str.charCodeAt(y) ^ s1[(s2[i] + s2[j2]) % 256])); | ||
var out = new Buffer(str, input_encoding || "utf8"), l = out.length; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)).toString(output_encoding || "hex"); | ||
return new Buffer(body(out, this.ksa, this.prga, new Buffer(l), l)).toString(output_encoding || "hex"); | ||
}, Rc4a.prototype.decodeString = function(str, input_encoding, output_encoding) { | ||
var out = new Buffer(str, input_encoding || "hex"), l = out.length; | ||
return new Buffer(body(out, this.ksa, new Buffer(l), l)).toString(output_encoding || "utf8"); | ||
return new Buffer(body(out, this.ksa, this.prga, new Buffer(l), l)).toString(output_encoding || "utf8"); | ||
}, Rc4a.prototype.encodeArray = Rc4a.prototype.decodeArray = function(arr) { | ||
var l = arr.length; | ||
return body(arr, this.ksa, new Array(l), l); | ||
return body(arr, this.ksa, this.prga, new Array(l), l); | ||
}, Rc4a.prototype.encodeBuffer = Rc4a.prototype.decodeBuffer = function(buff) { | ||
var l = buff.length; | ||
return body(buff, this.ksa, new Buffer(l), l); | ||
return body(buff, this.ksa, this.prga, new Buffer(l), l); | ||
}, Rc4a.prototype.encode = function(boh, input_encoding, output_encoding) { | ||
@@ -51,0 +59,0 @@ if ("string" == typeof boh) return this.encodeString(boh, input_encoding, output_encoding); |
"use strict"; | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
function gKsa(key) { | ||
@@ -14,2 +16,6 @@ for (var j = 0, s = box.slice(), len = key.length, i = 0; i < 256; ++i) s[j = (j + s[i] + key[i % len]) % 256] = [ s[i], s[i] = s[j] ][0]; | ||
module.exports = function(password) { | ||
return new Vmpc(password); | ||
}; | ||
function Vmpc(key) { | ||
@@ -19,7 +25,3 @@ this.key = null, this.ksa = null, this.change(key); | ||
var deprecate = require("util").deprecate, box = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 ]; | ||
module.exports = function(password) { | ||
return new Vmpc(password); | ||
}, Vmpc.prototype.change = function(key) { | ||
Vmpc.prototype.change = function(key) { | ||
if (this.key = new Array(key.length), Array.isArray(key)) this.key = key; else { | ||
@@ -26,0 +28,0 @@ if ("string" != typeof key && !Buffer.isBuffer(key)) throw new Error("Invalid data"); |
{ | ||
"version": "3.3.8", | ||
"version": "3.4.0", | ||
"name": "arc4", | ||
@@ -35,8 +35,8 @@ "description": "rc4 stream cipher", | ||
"grunt": "~1.0", | ||
"grunt-contrib-uglify": "~3.0", | ||
"grunt-contrib-uglify": "~3.3", | ||
"grunt-contrib-jshint": "~1.1", | ||
"grunt-endline": "~0.6", | ||
"grunt-safer-regex": "~0.0", | ||
"grunt-endline": "~0.7", | ||
"grunt-safer-regex": "~0.1", | ||
"istanbul": "~0.4", | ||
"mocha": "~3.4" | ||
"mocha": "~4.1" | ||
}, | ||
@@ -43,0 +43,0 @@ "engines": { |
Potential vulnerability
Supply chain riskInitial human review suggests the presence of a vulnerability in this package. It is pending further analysis and confirmation.
Found 2 instances in 1 package
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
134207
2597
2