Socket
Socket
Sign inDemoInstall

bcryptjs

Package Overview
Dependencies
0
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.1 to 2.2.2

2

bower.json
{
"name": "bcryptjs",
"description": "Optimized bcrypt in plain JavaScript with zero dependencies.",
"version": "2.2.1",
"version": "2.2.2",
"main": "dist/bcrypt-isaac.js",

@@ -6,0 +6,0 @@ "license": "New-BSD",

@@ -198,2 +198,24 @@ /*

/**
* Compares two strings of the same length in constant time.
* @param {string} known Must be of the correct length
* @param {string} unknown Must be the same length as `known`
* @returns {boolean}
* @inner
*/
function safeStringCompare(known, unknown) {
var right = 0,
wrong = 0;
for (var i=0, k=known.length; i<k; ++i) {
if (known.charCodeAt(i) === unknown.charCodeAt(i))
++right;
else
++wrong;
}
// Prevent removal of unused variables (never true, actually)
if (right < 0)
return false;
return wrong === 0;
}
/**
* Synchronously tests a string against a hash.

@@ -211,11 +233,3 @@ * @param {string} s String to compare

return false;
var comp = bcrypt.hashSync(s, hash.substr(0, hash.length-31)),
same = comp.length === hash.length,
max_length = (comp.length < hash.length) ? comp.length : hash.length;
// to prevent timing attacks, should check entire string
// don't exit after found to be false
for (var i = 0; i < max_length; ++i)
if (comp.length >= i && hash.length >= i && comp[i] != hash[i])
same = false;
return same;
return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length-31)), hash);
};

@@ -240,4 +254,11 @@

}
if (hash.length !== 60) {
nextTick(callback.bind(this, null, false));
return;
}
bcrypt.hash(s, hash.substr(0, 29), function(err, comp) {
callback(err, hash === comp);
if (err)
callback(err);
else
callback(null, safeStringCompare(comp, hash));
}, progressCallback);

@@ -1038,3 +1059,3 @@ };

if (progressCallback)
progressCallback(i/rounds);
progressCallback(i / rounds);
if (i < rounds) {

@@ -1041,0 +1062,0 @@ var start = Date.now();

@@ -6,19 +6,19 @@ (function(){/*

*/
function w(){function z(c){if("undefined"!==typeof module&&module&&module.exports)try{return require("crypto").randomBytes(c)}catch(a){}try{var b;(global.crypto||global.msCrypto).getRandomValues(b=new Uint32Array(c));return Array.prototype.slice.call(b)}catch(d){}if(!u)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return u(c)}function E(c){var a=[],b=0;F.f(function(){return b>=c.length?null:c.charCodeAt(b++)},function(b){a.push(b)});
return a}function v(c,a){var b=0,d=[],g,f;if(0>=a||a>c.length)throw Error("Illegal len: "+a);for(;b<a;){g=c[b++]&255;d.push(r[g>>2&63]);g=(g&3)<<4;if(b>=a){d.push(r[g&63]);break}f=c[b++]&255;g|=f>>4&15;d.push(r[g&63]);g=(f&15)<<2;if(b>=a){d.push(r[g&63]);break}f=c[b++]&255;g|=f>>6&3;d.push(r[g&63]);d.push(r[f&63])}return d.join("")}function A(c,a){var b=0,d=c.length,g=0,f=[],h,k,e;if(0>=a)throw Error("Illegal len: "+a);for(;b<d-1&&g<a;){e=c.charCodeAt(b++);h=e<p.length?p[e]:-1;e=c.charCodeAt(b++);
k=e<p.length?p[e]:-1;if(-1==h||-1==k)break;e=h<<2>>>0;e|=(k&48)>>4;f.push(x(e));if(++g>=a||b>=d)break;e=c.charCodeAt(b++);h=e<p.length?p[e]:-1;if(-1==h)break;e=(k&15)<<4>>>0;e|=(h&60)>>2;f.push(x(e));if(++g>=a||b>=d)break;e=c.charCodeAt(b++);k=e<p.length?p[e]:-1;e=(h&3)<<6>>>0;e|=k;f.push(x(e));++g}d=[];for(b=0;b<g;b++)d.push(f[b].charCodeAt(0));return d}function t(c,a,b,d){for(var g,f=c[a],h=c[a+1],f=f^b[0],k=0;14>=k;)g=d[f>>24&255],g+=d[256|f>>16&255],g^=d[512|f>>8&255],g+=d[768|f&255],h=h^g^b[++k],
g=d[h>>24&255],g+=d[256|h>>16&255],g^=d[512|h>>8&255],g+=d[768|h&255],f=f^g^b[++k];c[a]=h^b[17];c[a+1]=f;return c}function s(c,a){for(var b=0,d=0;4>b;++b)d=d<<8|c[a]&255,a=(a+1)%c.length;return{key:d,a:a}}function B(c,a,b){for(var d=0,g=[0,0],f=a.length,h=b.length,k,e=0;e<f;e++)k=s(c,d),d=k.a,a[e]^=k.key;for(e=0;e<f;e+=2)g=t(g,0,a,b),a[e]=g[0],a[e+1]=g[1];for(e=0;e<h;e+=2)g=t(g,0,a,b),b[e]=g[0],b[e+1]=g[1]}function G(c,a,b,d){for(var g=0,f=[0,0],h=b.length,k=d.length,e,m=0;m<h;m++)e=s(a,g),g=e.a,
b[m]^=e.key;for(m=g=0;m<h;m+=2)e=s(c,g),g=e.a,f[0]^=e.key,e=s(c,g),g=e.a,f[1]^=e.key,f=t(f,0,b,d),b[m]=f[0],b[m+1]=f[1];for(m=0;m<k;m+=2)e=s(c,g),g=e.a,f[0]^=e.key,e=s(c,g),g=e.a,f[1]^=e.key,f=t(f,0,b,d),d[m]=f[0],d[m+1]=f[1]}function C(c,a,b,d,g){function f(){g&&g(n/b);if(n<b)for(var e=Date.now();n<b&&!(n+=1,B(c,m,l),B(a,m,l),100<Date.now()-e););else{for(n=0;64>n;n++)for(p=0;p<k>>1;p++)t(h,p<<1,m,l);e=[];for(n=0;n<k;n++)e.push((h[n]>>24&255)>>>0),e.push((h[n]>>16&255)>>>0),e.push((h[n]>>8&255)>>>
0),e.push((h[n]&255)>>>0);if(d){d(null,e);return}return e}d&&q(f)}var h=D.slice(),k=h.length,e;if(4>b||31<b){e=Error("Illegal number of rounds (4-31): "+b);if(d){q(d.bind(this,e));return}throw e;}if(16!==a.length){e=Error("Illegal salt length: "+a.length+" != 16");if(d){q(d.bind(this,e));return}throw e;}b=1<<b>>>0;var m=H.slice(),l=I.slice(),n=0,p;G(a,c,m,l);if("undefined"!==typeof d)f();else for(;;)if("undefined"!==typeof(e=f()))return e||[]}function y(c,a,b,d){function g(b){var a=[];a.push("$2");
"a"<=f&&a.push(f);a.push("$");10>k&&a.push("0");a.push(k.toString());a.push("$");a.push(v(e,e.length));a.push(v(b,4*D.length-1));return a.join("")}if("string"!==typeof c||"string"!==typeof a){d=Error("Invalid string / salt: Not a string");if(b){q(b.bind(this,d));return}throw d;}var f,h;if("$"!==a.charAt(0)||"2"!==a.charAt(1)){d=Error("Invalid salt version: "+a.substring(0,2));if(b){q(b.bind(this,d));return}throw d;}if("$"===a.charAt(2))f=String.fromCharCode(0),h=3;else{f=a.charAt(2);if("a"!==f&&"y"!==
f||"$"!==a.charAt(3)){d=Error("Invalid salt revision: "+a.substring(2,4));if(b){q(b.bind(this,d));return}throw d;}h=4}if("$"<a.charAt(h+2)){d=Error("Missing salt rounds");if(b){q(b.bind(this,d));return}throw d;}var k=10*parseInt(a.substring(h,h+1),10)+parseInt(a.substring(h+1,h+2),10);a=a.substring(h+3,h+25);c=E(c+("a"<=f?"\x00":""));var e=A(a,16);if("undefined"==typeof b)return g(C(c,e,k));C(c,e,k,function(a,d){a?b(a,null):b(null,g(d))},d)}var l={},u=null;try{z(1)}catch(J){}u=null;l.l=function(c){u=
c};l.genSaltSync=function(c,a){if("undefined"===typeof c)c=10;else if("number"!==typeof c)throw Error("Illegal arguments: "+typeof c+", "+typeof a);if(4>c||31<c)throw Error("Illegal number of rounds (4-31): "+c);var b=[];b.push("$2a$");10>c&&b.push("0");b.push(c.toString());b.push("$");b.push(v(z(16),16));return b.join("")};l.genSalt=function(c,a,b){"function"===typeof a&&(b=a,a=void 0);"function"===typeof c&&(b=c,c=10);if("function"!==typeof b)throw Error("Illegal callback: "+typeof b);"number"!==
typeof c?q(b.bind(this,Error("Illegal arguments: "+typeof c))):q(function(){try{b(null,l.genSaltSync(c))}catch(a){b(a)}})};l.hashSync=function(c,a){"undefined"===typeof a&&(a=10);"number"===typeof a&&(a=l.genSaltSync(a));if("string"!==typeof c||"string"!==typeof a)throw Error("Illegal arguments: "+typeof c+", "+typeof a);return y(c,a)};l.hash=function(c,a,b,d){if("function"!==typeof b)throw Error("Illegal callback: "+typeof b);"string"===typeof c&&"number"===typeof a?l.genSalt(a,function(a,f){y(c,
f,b,d)}):"string"===typeof c&&"string"===typeof a?y(c,a,b,d):q(b.bind(this,Error("Illegal arguments: "+typeof c+", "+typeof a)))};l.compareSync=function(c,a){if("string"!==typeof c||"string"!==typeof a)throw Error("Illegal arguments: "+typeof c+", "+typeof a);if(60!==a.length)return!1;for(var b=l.hashSync(c,a.substr(0,a.length-31)),d=b.length===a.length,g=b.length<a.length?b.length:a.length,f=0;f<g;++f)b.length>=f&&a.length>=f&&b[f]!=a[f]&&(d=!1);return d};l.compare=function(c,a,b,d){if("function"!==
typeof b)throw Error("Illegal callback: "+typeof b);"string"!==typeof c||"string"!==typeof a?q(b.bind(this,Error("Illegal arguments: "+typeof c+", "+typeof a))):l.hash(c,a.substr(0,29),function(d,c){b(d,a===c)},d)};l.getRounds=function(c){if("string"!==typeof c)throw Error("Illegal arguments: "+typeof c);return parseInt(c.split("$")[2],10)};l.getSalt=function(c){if("string"!==typeof c)throw Error("Illegal arguments: "+typeof c);if(60!==c.length)throw Error("Illegal hash length: "+c.length+" != 60");
return c.substring(0,29)};var q="undefined"!==typeof process&&process&&"function"===typeof process.nextTick?"function"===typeof setImmediate?setImmediate:process.nextTick:setTimeout,r="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),p=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-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,-1,-1,-1,-1,-1,-1,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,-1,-1,-1,-1,-1],x=String.fromCharCode,F=function(){var c={h:1114111,g:function(a,b){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)128>d?b(d&127):(2048>d?b(d>>6&31|192):(65536>d?b(d>>12&15|224):(b(d>>18&7|240),b(d>>12&63|128)),b(d>>6&63|128)),b(d&63|128)),d=null},e:function(a,b){function d(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());
b.name="TruncatedError";b.bytes=a;throw b;}for(var c,f,h,k;null!==(c=a());)if(0===(c&128))b(c);else if(192===(c&224))null===(f=a())&&d([c,f]),b((c&31)<<6|f&63);else if(224===(c&240))null!==(f=a())&&null!==(h=a())||d([c,f,h]),b((c&15)<<12|(f&63)<<6|h&63);else if(240===(c&248))null!==(f=a())&&null!==(h=a())&&null!==(k=a())||d([c,f,h,k]),b((c&7)<<18|(f&63)<<12|(h&63)<<6|k&63);else throw RangeError("Illegal starting byte: "+c);},b:function(a,b){for(var d,c=null;null!==(d=null!==c?c:a());)55296<=d&&57343>=
d&&null!==(c=a())&&56320<=c&&57343>=c?(b(1024*(d-55296)+c-56320+65536),c=null):b(d);null!==c&&b(c)},d:function(a,b){var c=null;"number"===typeof a&&(c=a,a=function(){return null});for(;null!==c||null!==(c=a());)65535>=c?b(c):(c-=65536,b((c>>10)+55296),b(c%1024+56320)),c=null},f:function(a,b){c.b(a,function(a){c.g(a,b)})},k:function(a,b){c.e(a,function(a){c.d(a,b)})},c:function(a){return 128>a?1:2048>a?2:65536>a?3:4},j:function(a){for(var b,d=0;null!==(b=a());)d+=c.c(b);return d},i:function(a){var b=
0,d=0;c.b(a,function(a){++b;d+=c.c(a)});return[b,d]}};return c}();Date.now=Date.now||function(){return+new Date};var H=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],I=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,
function w(){function z(b){if("undefined"!==typeof module&&module&&module.exports)try{return require("crypto").randomBytes(b)}catch(a){}try{var c;(global.crypto||global.msCrypto).getRandomValues(c=new Uint32Array(b));return Array.prototype.slice.call(c)}catch(d){}if(!u)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return u(b)}function A(b,a){for(var c=0,d=0,f=0,g=b.length;f<g;++f)b.charCodeAt(f)===a.charCodeAt(f)?++c:++d;return 0>
c?!1:0===d}function F(b){var a=[],c=0;G.f(function(){return c>=b.length?null:b.charCodeAt(c++)},function(c){a.push(c)});return a}function v(b,a){var c=0,d=[],f,g;if(0>=a||a>b.length)throw Error("Illegal len: "+a);for(;c<a;){f=b[c++]&255;d.push(r[f>>2&63]);f=(f&3)<<4;if(c>=a){d.push(r[f&63]);break}g=b[c++]&255;f|=g>>4&15;d.push(r[f&63]);f=(g&15)<<2;if(c>=a){d.push(r[f&63]);break}g=b[c++]&255;f|=g>>6&3;d.push(r[f&63]);d.push(r[g&63])}return d.join("")}function B(b,a){var c=0,d=b.length,f=0,g=[],h,k,
e;if(0>=a)throw Error("Illegal len: "+a);for(;c<d-1&&f<a;){e=b.charCodeAt(c++);h=e<p.length?p[e]:-1;e=b.charCodeAt(c++);k=e<p.length?p[e]:-1;if(-1==h||-1==k)break;e=h<<2>>>0;e|=(k&48)>>4;g.push(x(e));if(++f>=a||c>=d)break;e=b.charCodeAt(c++);h=e<p.length?p[e]:-1;if(-1==h)break;e=(k&15)<<4>>>0;e|=(h&60)>>2;g.push(x(e));if(++f>=a||c>=d)break;e=b.charCodeAt(c++);k=e<p.length?p[e]:-1;e=(h&3)<<6>>>0;e|=k;g.push(x(e));++f}d=[];for(c=0;c<f;c++)d.push(g[c].charCodeAt(0));return d}function t(b,a,c,d){for(var f,
g=b[a],h=b[a+1],g=g^c[0],k=0;14>=k;)f=d[g>>24&255],f+=d[256|g>>16&255],f^=d[512|g>>8&255],f+=d[768|g&255],h=h^f^c[++k],f=d[h>>24&255],f+=d[256|h>>16&255],f^=d[512|h>>8&255],f+=d[768|h&255],g=g^f^c[++k];b[a]=h^c[17];b[a+1]=g;return b}function s(b,a){for(var c=0,d=0;4>c;++c)d=d<<8|b[a]&255,a=(a+1)%b.length;return{key:d,a:a}}function C(b,a,c){for(var d=0,f=[0,0],g=a.length,h=c.length,k,e=0;e<g;e++)k=s(b,d),d=k.a,a[e]^=k.key;for(e=0;e<g;e+=2)f=t(f,0,a,c),a[e]=f[0],a[e+1]=f[1];for(e=0;e<h;e+=2)f=t(f,0,
a,c),c[e]=f[0],c[e+1]=f[1]}function H(b,a,c,d){for(var f=0,g=[0,0],h=c.length,k=d.length,e,m=0;m<h;m++)e=s(a,f),f=e.a,c[m]^=e.key;for(m=f=0;m<h;m+=2)e=s(b,f),f=e.a,g[0]^=e.key,e=s(b,f),f=e.a,g[1]^=e.key,g=t(g,0,c,d),c[m]=g[0],c[m+1]=g[1];for(m=0;m<k;m+=2)e=s(b,f),f=e.a,g[0]^=e.key,e=s(b,f),f=e.a,g[1]^=e.key,g=t(g,0,c,d),d[m]=g[0],d[m+1]=g[1]}function D(b,a,c,d,f){function g(){f&&f(n/c);if(n<c)for(var e=Date.now();n<c&&!(n+=1,C(b,m,l),C(a,m,l),100<Date.now()-e););else{for(n=0;64>n;n++)for(p=0;p<k>>
1;p++)t(h,p<<1,m,l);e=[];for(n=0;n<k;n++)e.push((h[n]>>24&255)>>>0),e.push((h[n]>>16&255)>>>0),e.push((h[n]>>8&255)>>>0),e.push((h[n]&255)>>>0);if(d){d(null,e);return}return e}d&&q(g)}var h=E.slice(),k=h.length,e;if(4>c||31<c){e=Error("Illegal number of rounds (4-31): "+c);if(d){q(d.bind(this,e));return}throw e;}if(16!==a.length){e=Error("Illegal salt length: "+a.length+" != 16");if(d){q(d.bind(this,e));return}throw e;}c=1<<c>>>0;var m=I.slice(),l=J.slice(),n=0,p;H(a,b,m,l);if("undefined"!==typeof d)g();
else for(;;)if("undefined"!==typeof(e=g()))return e||[]}function y(b,a,c,d){function f(c){var a=[];a.push("$2");"a"<=g&&a.push(g);a.push("$");10>k&&a.push("0");a.push(k.toString());a.push("$");a.push(v(e,e.length));a.push(v(c,4*E.length-1));return a.join("")}if("string"!==typeof b||"string"!==typeof a){d=Error("Invalid string / salt: Not a string");if(c){q(c.bind(this,d));return}throw d;}var g,h;if("$"!==a.charAt(0)||"2"!==a.charAt(1)){d=Error("Invalid salt version: "+a.substring(0,2));if(c){q(c.bind(this,
d));return}throw d;}if("$"===a.charAt(2))g=String.fromCharCode(0),h=3;else{g=a.charAt(2);if("a"!==g&&"y"!==g||"$"!==a.charAt(3)){d=Error("Invalid salt revision: "+a.substring(2,4));if(c){q(c.bind(this,d));return}throw d;}h=4}if("$"<a.charAt(h+2)){d=Error("Missing salt rounds");if(c){q(c.bind(this,d));return}throw d;}var k=10*parseInt(a.substring(h,h+1),10)+parseInt(a.substring(h+1,h+2),10);a=a.substring(h+3,h+25);b=F(b+("a"<=g?"\x00":""));var e=B(a,16);if("undefined"==typeof c)return f(D(b,e,k));
D(b,e,k,function(a,d){a?c(a,null):c(null,f(d))},d)}var l={},u=null;try{z(1)}catch(K){}u=null;l.l=function(b){u=b};l.genSaltSync=function(b,a){if("undefined"===typeof b)b=10;else if("number"!==typeof b)throw Error("Illegal arguments: "+typeof b+", "+typeof a);if(4>b||31<b)throw Error("Illegal number of rounds (4-31): "+b);var c=[];c.push("$2a$");10>b&&c.push("0");c.push(b.toString());c.push("$");c.push(v(z(16),16));return c.join("")};l.genSalt=function(b,a,c){"function"===typeof a&&(c=a,a=void 0);
"function"===typeof b&&(c=b,b=10);if("function"!==typeof c)throw Error("Illegal callback: "+typeof c);"number"!==typeof b?q(c.bind(this,Error("Illegal arguments: "+typeof b))):q(function(){try{c(null,l.genSaltSync(b))}catch(a){c(a)}})};l.hashSync=function(b,a){"undefined"===typeof a&&(a=10);"number"===typeof a&&(a=l.genSaltSync(a));if("string"!==typeof b||"string"!==typeof a)throw Error("Illegal arguments: "+typeof b+", "+typeof a);return y(b,a)};l.hash=function(b,a,c,d){if("function"!==typeof c)throw Error("Illegal callback: "+
typeof c);"string"===typeof b&&"number"===typeof a?l.genSalt(a,function(a,g){y(b,g,c,d)}):"string"===typeof b&&"string"===typeof a?y(b,a,c,d):q(c.bind(this,Error("Illegal arguments: "+typeof b+", "+typeof a)))};l.compareSync=function(b,a){if("string"!==typeof b||"string"!==typeof a)throw Error("Illegal arguments: "+typeof b+", "+typeof a);return 60!==a.length?!1:A(l.hashSync(b,a.substr(0,a.length-31)),a)};l.compare=function(b,a,c,d){if("function"!==typeof c)throw Error("Illegal callback: "+typeof c);
"string"!==typeof b||"string"!==typeof a?q(c.bind(this,Error("Illegal arguments: "+typeof b+", "+typeof a))):60!==a.length?q(c.bind(this,null,!1)):l.hash(b,a.substr(0,29),function(d,b){d?c(d):c(null,A(b,a))},d)};l.getRounds=function(b){if("string"!==typeof b)throw Error("Illegal arguments: "+typeof b);return parseInt(b.split("$")[2],10)};l.getSalt=function(b){if("string"!==typeof b)throw Error("Illegal arguments: "+typeof b);if(60!==b.length)throw Error("Illegal hash length: "+b.length+" != 60");
return b.substring(0,29)};var q="undefined"!==typeof process&&process&&"function"===typeof process.nextTick?"function"===typeof setImmediate?setImmediate:process.nextTick:setTimeout,r="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),p=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-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,-1,-1,-1,-1,-1,-1,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,-1,-1,-1,-1,-1],x=String.fromCharCode,G=function(){var b={h:1114111,g:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)128>d?c(d&127):(2048>d?c(d>>6&31|192):(65536>d?c(d>>12&15|224):(c(d>>18&7|240),c(d>>12&63|128)),c(d>>6&63|128)),c(d&63|128)),d=null},e:function(a,c){function d(a){a=a.slice(0,a.indexOf(null));var c=Error(a.toString());
c.name="TruncatedError";c.bytes=a;throw c;}for(var b,g,h,k;null!==(b=a());)if(0===(b&128))c(b);else if(192===(b&224))null===(g=a())&&d([b,g]),c((b&31)<<6|g&63);else if(224===(b&240))null!==(g=a())&&null!==(h=a())||d([b,g,h]),c((b&15)<<12|(g&63)<<6|h&63);else if(240===(b&248))null!==(g=a())&&null!==(h=a())&&null!==(k=a())||d([b,g,h,k]),c((b&7)<<18|(g&63)<<12|(h&63)<<6|k&63);else throw RangeError("Illegal starting byte: "+b);},b:function(a,c){for(var d,b=null;null!==(d=null!==b?b:a());)55296<=d&&57343>=
d&&null!==(b=a())&&56320<=b&&57343>=b?(c(1024*(d-55296)+b-56320+65536),b=null):c(d);null!==b&&c(b)},d:function(a,c){var b=null;"number"===typeof a&&(b=a,a=function(){return null});for(;null!==b||null!==(b=a());)65535>=b?c(b):(b-=65536,c((b>>10)+55296),c(b%1024+56320)),b=null},f:function(a,c){b.b(a,function(a){b.g(a,c)})},k:function(a,c){b.e(a,function(a){b.d(a,c)})},c:function(a){return 128>a?1:2048>a?2:65536>a?3:4},j:function(a){for(var c,d=0;null!==(c=a());)d+=b.c(c);return d},i:function(a){var c=
0,d=0;b.b(a,function(a){++c;d+=b.c(a)});return[c,d]}};return b}();Date.now=Date.now||function(){return+new Date};var I=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],J=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,
1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,

@@ -45,3 +45,3 @@ 3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,

3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,
4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],D=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];l.encodeBase64=v;l.decodeBase64=A;return l}
4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],E=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];l.encodeBase64=v;l.decodeBase64=B;return l}
"function"===typeof define&&define.amd?define([],w):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=w():(this.dcodeIO=this.dcodeIO||{}).bcrypt=w();})();
{
"name": "bcryptjs",
"description": "Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.",
"version": "2.2.1",
"version": "2.2.2",
"author": "Daniel Wirtz <dcode@dcode.io>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -158,2 +158,24 @@ /**

/**
* Compares two strings of the same length in constant time.
* @param {string} known Must be of the correct length
* @param {string} unknown Must be the same length as `known`
* @returns {boolean}
* @inner
*/
function safeStringCompare(known, unknown) {
var right = 0,
wrong = 0;
for (var i=0, k=known.length; i<k; ++i) {
if (known.charCodeAt(i) === unknown.charCodeAt(i))
++right;
else
++wrong;
}
// Prevent removal of unused variables (never true, actually)
if (right < 0)
return false;
return wrong === 0;
}
/**
* Synchronously tests a string against a hash.

@@ -171,11 +193,3 @@ * @param {string} s String to compare

return false;
var comp = bcrypt.hashSync(s, hash.substr(0, hash.length-31)),
same = comp.length === hash.length,
max_length = (comp.length < hash.length) ? comp.length : hash.length;
// to prevent timing attacks, should check entire string
// don't exit after found to be false
for (var i = 0; i < max_length; ++i)
if (comp.length >= i && hash.length >= i && comp[i] != hash[i])
same = false;
return same;
return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length-31)), hash);
};

@@ -200,4 +214,11 @@

}
if (hash.length !== 60) {
nextTick(callback.bind(this, null, false));
return;
}
bcrypt.hash(s, hash.substr(0, 29), function(err, comp) {
callback(err, hash === comp);
if (err)
callback(err);
else
callback(null, safeStringCompare(comp, hash));
}, progressCallback);

@@ -204,0 +225,0 @@ };

@@ -422,3 +422,3 @@ /**

if (progressCallback)
progressCallback(i/rounds);
progressCallback(i / rounds);
if (i < rounds) {

@@ -425,0 +425,0 @@ var start = Date.now();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc