Socket
Socket
Sign inDemoInstall

argon2

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argon2 - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

argon2/include/argon2.h

28

argon2/README.md

@@ -5,3 +5,3 @@ # Argon2

function that won the [Password Hashing Competition
(PHC)](https://password-hashing.net).
(PHC)](https://password-hashing.net).

@@ -19,3 +19,3 @@ You should use Argon2 whenever you need to hash passwords for credential

therefore the execution time, given in number of iterations
* A **memory** cost, which defines the memory usage, given in kibibytes
* A **memory** cost, which defines the memory usage, given in kibibytes
* A **parallelism** degree, which defines the number of parallel threads

@@ -73,3 +73,3 @@

parameters, the low-level API additionally takes parallelism parameters
and several others, as defined in [`src/argon2.h`](src/argon2.h).
and several others, as defined in [`include/argon2.h`](include/argon2.h).

@@ -116,8 +116,8 @@

argon2_context context = {
hash2, HASHLEN,
pwd, pwdlen,
hash2, HASHLEN,
pwd, pwdlen,
salt, SALTLEN,
NULL, 0, /* secret data */
NULL, 0, /* associated data */
t_cost, m_cost, parallelism, parallelism,
t_cost, m_cost, parallelism, parallelism,
NULL, NULL, /* custom memory allocation / deallocation functions */

@@ -147,3 +147,3 @@ ARGON2_DEFAULT_FLAGS /* by default the password is zeroed on exit */

See [`src/argon2.h`](src/argon2.h) for API detais.
See [`include/argon2.h`](include/argon2.h) for API details.

@@ -186,4 +186,18 @@ *Note: in this example the salt is set to the all-`0x00` string for the

## Bindings
Bindings are available for the following languages (make sure to read
their documentation):
* [Go](https://github.com/tvdburgt/go-argon2) by [@tvdburgt](https://github.com/tvdburgt)
* [Haskell](https://hackage.haskell.org/package/argon2-1.0.0/docs/Crypto-Argon2.html) by [@ocharles](https://github.com/ocharles)
* [Javascript](https://github.com/ranisalt/node-argon2), by [@ranisalt](https://github.com/ranisalt)
* [JVM](https://github.com/phxql/argon2-jvm) by [@phXql](https://github.com/phxql)
* [Lua](https://github.com/thibaultCha/lua-argon2) by [@thibaultCha](https://github.com/thibaultCha)
* [OCaml](https://github.com/Khady/ocaml-argon2) by [@Khady](https://github.com/Khady)
* [Python](https://pypi.python.org/pypi/argon2), by [@flamewow](https://github.com/flamewow)
* [Python](https://pypi.python.org/pypi/argon2_cffi), by [@hynek](https://github.com/hynek)
* [Ruby](https://github.com/technion/ruby-argon2) by [@technion](https://github.com/technion)
* [Rust](https://github.com/quininer/argon2-rs) by [@quininer](https://github.com/quininer)
## Intellectual property

@@ -190,0 +204,0 @@

@@ -1,3 +0,3 @@

var bindings = require("bindings")("argon2"),
crypto = require("crypto");
var bindings = require('bindings')('argon2'),
crypto = require('crypto');

@@ -14,3 +14,3 @@ var defaults = exports.defaults = Object.freeze({

if (typeof(callback) === "undefined") {
if (typeof(callback) === 'undefined') {
throw error;

@@ -26,26 +26,41 @@ } else {

if (salt.length > 16) {
fail("Salt too long, maximum 16 characters.", callback);
fail('Salt too long, maximum 16 characters.', callback);
return false;
}
Object.assign(options, Object.assign({}, defaults, options));
for (var key in defaults) {
options[key] = options[key] || defaults[key];
}
if (isNaN(options.timeCost)) {
fail("Invalid time cost, must be a number.", callback);
fail('Invalid time cost, must be a number.', callback);
return false;
} else if (options.timeCost <= 0) {
fail('Time cost too low, minimum of 1.', callback);
return false;
} else if (options.timeCost >= 4294967296) {
fail('Time cost too high, maximum of 4294967295.', callback);
return false;
}
if (isNaN(options.memoryCost)) {
fail("Invalid memory cost, must be a number.", callback);
fail('Invalid memory cost, must be a number.', callback);
return false;
}
if (options.memoryCost >= 32) {
fail("Memory cost too high, maximum of 32.", callback);
} else if (options.memoryCost <= 0) {
fail('Memory cost too low, minimum of 1.', callback);
return false;
} else if (options.memoryCost >= 32) {
fail('Memory cost too high, maximum of 31.', callback);
return false;
}
if (isNaN(options.parallelism)) {
fail("Invalid parallelism, must be a number.", callback);
fail('Invalid parallelism, must be a number.', callback);
return false;
} else if (options.parallelism <= 0) {
fail('Parallelism too low, minimum of 1.', callback);
return false;
} else if (options.parallelism >= 4294967296) {
fail('Parallelism too high, maximum of 4294967295.', callback);
return false;
}

@@ -59,9 +74,11 @@

exports.hash = function (plain, salt, options, callback) {
"use strict";
'use strict';
if (!callback) {
callback = options;
options = {};
options = defaults;
}
options = Object.assign({}, options);
if (validate(salt, options, callback)) {

@@ -74,5 +91,5 @@ return bindings.hash(plain, salt, options.timeCost, options.memoryCost,

exports.hashSync = function (plain, salt, options) {
"use strict";
'use strict';
options = options || {};
options = Object.assign({}, options || defaults);

@@ -86,3 +103,3 @@ if (validate(salt, options)) {

exports.generateSalt = function (callback) {
"use strict";
'use strict';

@@ -95,3 +112,3 @@ crypto.randomBytes(16, function (err, buffer) {

exports.generateSaltSync = function () {
"use strict";
'use strict';

@@ -102,3 +119,3 @@ return crypto.randomBytes(16).toString();

exports.verify = function (hash, plain, callback) {
"use strict";
'use strict';

@@ -109,3 +126,3 @@ return bindings.verify(hash, plain, /argon2d/.test(hash), callback);

exports.verifySync = function (hash, plain) {
"use strict";
'use strict';

@@ -112,0 +129,0 @@ return bindings.verifySync(hash, plain, /argon2d/.test(hash));

{
"name": "argon2",
"version": "0.5.1",
"version": "0.6.0",
"description": "An Argon2 library for Node",
"main": "index.js",
"scripts": {
"benchmark": "node benchmark.js",
"build": "node-gyp configure rebuild",
"clean": "node-gyp clean",
"preinstall": "git submodule update --init",
"postinstall": "npm run build",

@@ -32,7 +32,12 @@ "test": "nodeunit test.spec.js"

"bindings": "^1.2.1",
"nan": "^2.1.0"
"nan": "^2.2.0"
},
"devDependencies": {
"async": "^1.5.2",
"async-benchmark": "^1.0.1",
"nodeunit": "^0.9.1"
},
"engines": {
"node": ">=4.0.0"
}
}

@@ -1,2 +0,2 @@

# node-argon2 [![NPM package][npm-image]][npm-url] [![Build status][codeship-image]][codeship-url] [![Coverage status][coverage-image]][coverage-url] [![Code Climate][codeclimate-image]][codeclimate-url] [![Dependencies][david-dm-image]][david-dm-url]
# node-argon2 [![NPM package][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Coverage status][coverage-image]][coverage-url] [![Code Climate][codeclimate-image]][codeclimate-url] [![Dependencies][david-dm-image]][david-dm-url]
Bindings to the reference [Argon2](https://github.com/P-H-C/phc-winner-argon2)

@@ -7,2 +7,3 @@ implementation.

You **MUST** have a **node-gyp** global install before proceeding with install.
**node-argon2** works only and is tested against >=4.0.0 .

@@ -19,3 +20,3 @@ ### Usage

argon2.hash('password', 'somesalt', function (err, hash) {
if (err) // hashion failure
if (err) // hashing failure
throw err;

@@ -130,4 +131,4 @@

[npm-url]: https://www.npmjs.com/package/argon2
[codeship-image]: https://img.shields.io/codeship/eb7243d0-f615-0132-1cce-020cea137f51/master.svg?style=flat-square
[codeship-url]: https://codeship.com/projects/85936
[travis-image]: https://img.shields.io/travis/ranisalt/node-argon2/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/ranisalt/node-argon2
[coverage-image]: https://img.shields.io/coveralls/ranisalt/node-argon2/master.svg?style=flat-square

@@ -134,0 +135,0 @@ [coverage-url]: https://coveralls.io/github/ranisalt/node-argon2

@@ -6,4 +6,4 @@ var argon2 = process.env.COVERAGE

module.exports = {
test_defaults: function (assert) {
"use strict";
test_defaults(assert) {
'use strict';

@@ -21,10 +21,10 @@ assert.expect(1);

test_hash: function (assert) {
"use strict";
test_hash(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.equal(hash, "$argon2i$m=4096,t=3,p=1$c29tZXNhbHQAAAAAAAAAAA$FHF/OZ0GJpMRAlBmPTqXxw36Ftp87JllALZPcP9w9gs");
argon2.hash('password', 'somesalt', function (err, hash) {
assert.ok(hash, 'Hash should be defined.');
assert.equal(hash, '$argon2i$m=4096,t=3,p=1$c29tZXNhbHQAAAAAAAAAAA$FHF/OZ0GJpMRAlBmPTqXxw36Ftp87JllALZPcP9w9gs');
assert.equal(undefined, err);

@@ -35,12 +35,12 @@ assert.done();

test_hash_argon2d: function (assert) {
"use strict";
test_hash_argon2d(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2.hash('password', 'somesalt', {
argon2d: true
}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/\$argon2d\$/.test(hash), "Should have argon2d signature.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/\$argon2d\$/.test(hash), 'Should have argon2d signature.');
assert.equal(undefined, err);

@@ -51,12 +51,12 @@ assert.done();

test_hash_truthy_argon2d: function (assert) {
"use strict";
test_hash_truthy_argon2d(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2d: "foo"
argon2.hash('password', 'somesalt', {
argon2d: 'foo'
}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/\$argon2d\$/.test(hash), "Should have argon2d signature.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/\$argon2d\$/.test(hash), 'Should have argon2d signature.');
assert.equal(undefined, err);

@@ -67,12 +67,12 @@ assert.done();

test_hash_falsy_argon2d: function (assert) {
"use strict";
test_hash_falsy_argon2d(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2d: ""
argon2.hash('password', 'somesalt', {
argon2d: ''
}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/\$argon2i\$/.test(hash), "Should not have argon2d signature.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/\$argon2i\$/.test(hash), 'Should not have argon2d signature.');
assert.equal(undefined, err);

@@ -83,10 +83,10 @@ assert.done();

test_hash_long_salt: function (assert) {
"use strict";
test_hash_long_salt(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesaltwaytoobig", function (err, hash) {
assert.ok(err, "Error should be defined.");
assert.equal(err.message, "Salt too long, maximum 16 characters.");
argon2.hash('password', 'somesaltwaytoobig', function (err, hash) {
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Salt too long, maximum 16 characters.');
assert.equal(undefined, hash);

@@ -97,12 +97,12 @@ assert.done();

test_hash_time_cost: function (assert) {
"use strict";
test_hash_time_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2.hash('password', 'somesalt', {
timeCost: 4
}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/t=4/.test(hash), "Should have correct time cost.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/t=4/.test(hash), 'Should have correct time cost.');
assert.equal(undefined, err);

@@ -113,12 +113,12 @@ assert.done();

test_hash_invalid_time_cost: function (assert) {
"use strict";
test_hash_invalid_time_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
timeCost: "foo"
argon2.hash('password', 'somesalt', {
timeCost: 'foo'
}, function (err, hash) {
assert.ok(err, "Error should be defined.");
assert.equal(err.message, "Invalid time cost, must be a number.");
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Invalid time cost, must be a number.');
assert.equal(undefined, hash);

@@ -129,12 +129,42 @@ assert.done();

test_hash_memory_cost: function (assert) {
"use strict";
test_hash_low_time_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2.hash('password', 'somesalt', {
timeCost: -4294967290
}, function (err, hash) {
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Time cost too low, minimum of 1.');
assert.equal(undefined, hash);
assert.done();
});
},
test_hash_high_time_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash('password', 'somesalt', {
timeCost: 4294967297
}, function (err, hash) {
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Time cost too high, maximum of 4294967295.');
assert.equal(undefined, hash);
assert.done();
});
},
test_hash_memory_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash('password', 'somesalt', {
memoryCost: 13
}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/m=8192/.test(hash), "Should have correct memory cost.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/m=8192/.test(hash), 'Should have correct memory cost.');
assert.equal(undefined, err);

@@ -145,12 +175,12 @@ assert.done();

test_hash_invalid_memory_cost: function (assert) {
"use strict";
test_hash_invalid_memory_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
memoryCost: "foo"
argon2.hash('password', 'somesalt', {
memoryCost: 'foo'
}, function (err, hash) {
assert.ok(err, "Error should be defined.");
assert.equal(err.message, "Invalid memory cost, must be a number.");
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Invalid memory cost, must be a number.');
assert.equal(undefined, hash);

@@ -161,12 +191,27 @@ assert.done();

test_hash_high_memory_cost: function (assert) {
"use strict";
test_hash_low_memory_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2.hash('password', 'somesalt', {
memoryCost: -4294967290
}, function (err, hash) {
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Memory cost too low, minimum of 1.');
assert.equal(undefined, hash);
assert.done();
});
},
test_hash_high_memory_cost(assert) {
'use strict';
assert.expect(3);
argon2.hash('password', 'somesalt', {
memoryCost: 32
}, function (err, hash) {
assert.ok(err, "Error should be defined.");
assert.equal(err.message, "Memory cost too high, maximum of 32.");
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Memory cost too high, maximum of 31.');
assert.equal(undefined, hash);

@@ -177,12 +222,12 @@ assert.done();

test_hash_parallelism: function (assert) {
"use strict";
test_hash_parallelism(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2.hash('password', 'somesalt', {
parallelism: 2
}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/p=2/.test(hash), "Should have correct parallelism.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/p=2/.test(hash), 'Should have correct parallelism.');
assert.equal(undefined, err);

@@ -193,12 +238,12 @@ assert.done();

test_hash_invalid_parallelism: function (assert) {
"use strict";
test_hash_invalid_parallelism(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
parallelism: "foo"
argon2.hash('password', 'somesalt', {
parallelism: 'foo'
}, function (err, hash) {
assert.ok(err, "Error should be defined.");
assert.equal(err.message, "Invalid parallelism, must be a number.");
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Invalid parallelism, must be a number.');
assert.equal(undefined, hash);

@@ -209,8 +254,38 @@ assert.done();

test_hash_all_options: function (assert) {
"use strict";
test_hash_low_parallelism(assert) {
'use strict';
assert.expect(3);
argon2.hash("password", "somesalt", {
argon2.hash('password', 'somesalt', {
parallelism: -4294967290
}, function (err, hash) {
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Parallelism too low, minimum of 1.');
assert.equal(undefined, hash);
assert.done();
});
},
test_hash_high_parallelism(assert) {
'use strict';
assert.expect(3);
argon2.hash('password', 'somesalt', {
parallelism: 4294967297
}, function (err, hash) {
assert.ok(err, 'Error should be defined.');
assert.equal(err.message, 'Parallelism too high, maximum of 4294967295.');
assert.equal(undefined, hash);
assert.done();
});
},
test_hash_all_options(assert) {
'use strict';
assert.expect(3);
argon2.hash('password', 'somesalt', {
timeCost: 4,

@@ -220,4 +295,4 @@ memoryCost: 13,

}, function (err, hash) {
assert.ok(hash, "Hash should be defined.");
assert.ok(/m=8192,t=4,p=2/.test(hash), "Should have correct options.");
assert.ok(hash, 'Hash should be defined.');
assert.ok(/m=8192,t=4,p=2/.test(hash), 'Should have correct options.');
assert.equal(undefined, err);

@@ -228,62 +303,62 @@ assert.done();

test_hash_sync: function (assert) {
"use strict";
test_hash_sync(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt");
assert.equal(hash, "$argon2i$m=4096,t=3,p=1$c29tZXNhbHQAAAAAAAAAAA$FHF/OZ0GJpMRAlBmPTqXxw36Ftp87JllALZPcP9w9gs");
var hash = argon2.hashSync('password', 'somesalt');
assert.equal(hash, '$argon2i$m=4096,t=3,p=1$c29tZXNhbHQAAAAAAAAAAA$FHF/OZ0GJpMRAlBmPTqXxw36Ftp87JllALZPcP9w9gs');
assert.done();
},
test_hash_argon2d_sync: function (assert) {
"use strict";
test_hash_argon2d_sync(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
var hash = argon2.hashSync('password', 'somesalt', {
argon2d: true
});
assert.ok(/\$argon2d\$/.test(hash), "Should use argon2d signature.");
assert.ok(/\$argon2d\$/.test(hash), 'Should use argon2d signature.');
assert.done();
},
test_hash_truthy_argon2d_sync: function (assert) {
"use strict";
test_hash_truthy_argon2d_sync(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
argon2d: "foo"
var hash = argon2.hashSync('password', 'somesalt', {
argon2d: 'foo'
});
assert.ok(/\$argon2d\$/.test(hash), "Should use argon2d signature.");
assert.ok(/\$argon2d\$/.test(hash), 'Should use argon2d signature.');
assert.done();
},
test_hash_falsy_argon2d_sync: function (assert) {
"use strict";
test_hash_falsy_argon2d_sync(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
argon2d: ""
var hash = argon2.hashSync('password', 'somesalt', {
argon2d: ''
});
assert.ok(/\$argon2i\$/.test(hash), "Should not use argon2d signature.");
assert.ok(/\$argon2i\$/.test(hash), 'Should not use argon2d signature.');
assert.done();
},
test_hash_sync_time_cost: function (assert) {
"use strict";
test_hash_sync_time_cost(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
var hash = argon2.hashSync('password', 'somesalt', {
timeCost: 4
});
assert.ok(/t=4/.test(hash), "Should have correct time cost.");
assert.ok(/t=4/.test(hash), 'Should have correct time cost.');
assert.done();
},
test_hash_sync_invalid_time_cost: function (assert) {
"use strict";
test_hash_sync_invalid_time_cost(assert) {
'use strict';

@@ -293,23 +368,49 @@ assert.expect(1);

assert.throws(function () {
var hash = argon2.hashSync("password", "somesalt", {
timeCost: "foo"
var hash = argon2.hashSync('password', 'somesalt', {
timeCost: 'foo'
});
});
}, /invalid/i);
assert.done();
},
test_hash_sync_memory_cost: function (assert) {
"use strict";
test_hash_sync_low_time_cost(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
assert.throws(function () {
var hash = argon2.hashSync('password', 'somesalt', {
timeCost: -4294967290
});
}, /too low/);
assert.done();
},
test_hash_sync_high_time_cost(assert) {
'use strict';
assert.expect(1);
assert.throws(function () {
var hash = argon2.hashSync('password', 'somesalt', {
timeCost: 4294967297
});
}, /too high/);
assert.done();
},
test_hash_sync_memory_cost(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync('password', 'somesalt', {
memoryCost: 13
});
assert.ok(/m=8192/.test(hash), "Should have correct memory cost.");
assert.ok(/m=8192/.test(hash), 'Should have correct memory cost.');
assert.done();
},
test_hash_sync_invalid_memory_cost: function (assert) {
"use strict";
test_hash_sync_invalid_memory_cost(assert) {
'use strict';

@@ -319,11 +420,11 @@ assert.expect(1);

assert.throws(function () {
var hash = argon2.hashSync("password", "somesalt", {
memoryCost: "foo"
var hash = argon2.hashSync('password', 'somesalt', {
memoryCost: 'foo'
});
});
}, /invalid/i);
assert.done();
},
test_hash_sync_high_memory_cost: function (assert) {
"use strict";
test_hash_sync_low_memory_cost(assert) {
'use strict';

@@ -333,23 +434,36 @@ assert.expect(1);

assert.throws(function () {
argon2.hashSync("password", "somesalt", {
var hash = argon2.hashSync('password', 'somesalt', {
memoryCost: -4294967290
});
}, /too low/);
assert.done();
},
test_hash_sync_high_memory_cost(assert) {
'use strict';
assert.expect(1);
assert.throws(function () {
argon2.hashSync('password', 'somesalt', {
memoryCost: 32
});
});
}, /too high/);
assert.done();
},
test_hash_sync_parallelism: function (assert) {
"use strict";
test_hash_sync_parallelism(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
var hash = argon2.hashSync('password', 'somesalt', {
parallelism: 2
});
assert.ok(/p=2/.test(hash), "Should have correct parallelism.");
assert.ok(/p=2/.test(hash), 'Should have correct parallelism.');
assert.done();
},
test_hash_sync_invalid_parallelism: function (assert) {
"use strict";
test_hash_sync_invalid_parallelism(assert) {
'use strict';

@@ -359,15 +473,41 @@ assert.expect(1);

assert.throws(function () {
var hash = argon2.hashSync("password", "somesalt", {
parallelism: "foo"
var hash = argon2.hashSync('password', 'somesalt', {
parallelism: 'foo'
});
});
}, /invalid/i);
assert.done();
},
test_hash_sync_all_options: function (assert) {
"use strict";
test_hash_sync_low_parallelism(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync("password", "somesalt", {
assert.throws(function () {
var hash = argon2.hashSync('password', 'somesalt', {
parallelism: -4294967290
});
}, /too low/);
assert.done();
},
test_hash_sync_high_parallelism(assert) {
'use strict';
assert.expect(1);
assert.throws(function () {
var hash = argon2.hashSync('password', 'somesalt', {
parallelism: 4294967297
});
}, /too high/);
assert.done();
},
test_hash_sync_all_options(assert) {
'use strict';
assert.expect(1);
var hash = argon2.hashSync('password', 'somesalt', {
timeCost: 4,

@@ -377,8 +517,8 @@ memoryCost: 13,

});
assert.ok(/m=8192,t=4,p=2/.test(hash), "Should have correct options.");
assert.ok(/m=8192,t=4,p=2/.test(hash), 'Should have correct options.');
assert.done();
},
test_hash_sync_long_salt: function (assert) {
"use strict";
test_hash_sync_long_salt(assert) {
'use strict';

@@ -388,3 +528,3 @@ assert.expect(1);

assert.throws(function () {
argon2.hashSync("password", "somesaltwaytoobig");
argon2.hashSync('password', 'somesaltwaytoobig');
});

@@ -394,4 +534,4 @@ assert.done();

test_generate_salt: function (assert) {
"use strict";
test_generate_salt(assert) {
'use strict';

@@ -406,4 +546,4 @@ assert.expect(1);

test_generate_salt_sync: function (assert) {
"use strict";
test_generate_salt_sync(assert) {
'use strict';

@@ -416,9 +556,9 @@ assert.expect(1);

test_verify_ok: function (assert) {
"use strict";
test_verify_ok(assert) {
'use strict';
assert.expect(1);
argon2.verify(argon2.hashSync("password", argon2.generateSaltSync()),
"password", function (err) {
argon2.verify(argon2.hashSync('password', argon2.generateSaltSync()),
'password', function (err) {
assert.equal(undefined, err);

@@ -429,10 +569,10 @@ assert.done();

test_verify_fail: function (assert) {
"use strict";
test_verify_fail(assert) {
'use strict';
assert.expect(1);
argon2.verify(argon2.hashSync("password", argon2.generateSaltSync()),
"passwolrd", function (err) {
assert.ok(err, "Error should be defined.");
argon2.verify(argon2.hashSync('password', argon2.generateSaltSync()),
'passwolrd', function (err) {
assert.ok(err, 'Error should be defined.');
assert.done();

@@ -442,11 +582,11 @@ });

test_verify_argon2d_ok: function (assert) {
"use strict";
test_verify_argon2d_ok(assert) {
'use strict';
assert.expect(1);
argon2.hash("password", argon2.generateSaltSync(), {
argon2.hash('password', argon2.generateSaltSync(), {
argon2d: true
}, function (err, hash) {
argon2.verify(hash, "password", function (err) {
argon2.verify(hash, 'password', function (err) {
assert.equal(undefined, err);

@@ -458,12 +598,12 @@ assert.done();

test_verify_argon2d_fail: function (assert) {
"use strict";
test_verify_argon2d_fail(assert) {
'use strict';
assert.expect(1);
argon2.hash("password", argon2.generateSaltSync(), {
argon2.hash('password', argon2.generateSaltSync(), {
argon2d: true
}, function (err, hash) {
argon2.verify(hash, "passwolrd", function (err) {
assert.ok(err, "Error should be defined.");
argon2.verify(hash, 'passwolrd', function (err) {
assert.ok(err, 'Error should be defined.');
assert.done();

@@ -474,31 +614,31 @@ });

test_verify_sync_ok: function (assert) {
"use strict";
test_verify_sync_ok(assert) {
'use strict';
assert.expect(1);
assert.equal(true, argon2.verifySync(argon2.hashSync("password",
argon2.generateSaltSync()), "password"));
assert.equal(true, argon2.verifySync(argon2.hashSync('password',
argon2.generateSaltSync()), 'password'));
assert.done();
},
test_verify_sync_fail: function (assert) {
"use strict";
test_verify_sync_fail(assert) {
'use strict';
assert.expect(1);
assert.equal(false, argon2.verifySync(argon2.hashSync("password",
argon2.generateSaltSync()), "passworld"));
assert.equal(false, argon2.verifySync(argon2.hashSync('password',
argon2.generateSaltSync()), 'passworld'));
assert.done();
},
test_verify_argon2d_sync_ok: function (assert) {
"use strict";
test_verify_argon2d_sync_ok(assert) {
'use strict';
assert.expect(1);
argon2.hash("password", argon2.generateSaltSync(), {
argon2.hash('password', argon2.generateSaltSync(), {
argon2d: true
}, function (err, hash) {
assert.equal(true, argon2.verifySync(hash, "password"));
assert.equal(true, argon2.verifySync(hash, 'password'));
assert.done();

@@ -508,11 +648,11 @@ });

test_verify_argon2d_sync_fail: function (assert) {
"use strict";
test_verify_argon2d_sync_fail(assert) {
'use strict';
assert.expect(1);
argon2.hash("password", argon2.generateSaltSync(), {
argon2.hash('password', argon2.generateSaltSync(), {
argon2d: true
}, function (err, hash) {
assert.equal(false, argon2.verifySync(hash, "passwolrd"));
assert.equal(false, argon2.verifySync(hash, 'passwolrd'));
assert.done();

@@ -519,0 +659,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc