Comparing version 0.4.2 to 0.5.0
18
index.js
@@ -56,3 +56,3 @@ var bindings = require("bindings")("argon2"), | ||
exports.encrypt = function (plain, salt, options, callback) { | ||
exports.hash = function (plain, salt, options, callback) { | ||
"use strict"; | ||
@@ -66,3 +66,3 @@ | ||
if (validate(salt, options, callback)) { | ||
return bindings.encrypt(plain, salt, options.timeCost, options.memoryCost, | ||
return bindings.hash(plain, salt, options.timeCost, options.memoryCost, | ||
options.parallelism, options.argon2d, callback); | ||
@@ -72,3 +72,3 @@ } | ||
exports.encryptSync = function (plain, salt, options) { | ||
exports.hashSync = function (plain, salt, options) { | ||
"use strict"; | ||
@@ -79,4 +79,4 @@ | ||
if (validate(salt, options)) { | ||
return bindings.encryptSync(plain, salt, options.timeCost, | ||
options.memoryCost, options.parallelism, options.argon2d); | ||
return bindings.hashSync(plain, salt, options.timeCost, options.memoryCost, | ||
options.parallelism, options.argon2d); | ||
} | ||
@@ -99,13 +99,13 @@ }; | ||
exports.verify = function (encrypted, plain, callback) { | ||
exports.verify = function (hash, plain, callback) { | ||
"use strict"; | ||
return bindings.verify(encrypted, plain, /argon2d/.test(encrypted), callback); | ||
return bindings.verify(hash, plain, /argon2d/.test(hash), callback); | ||
}; | ||
exports.verifySync = function (encrypted, plain) { | ||
exports.verifySync = function (hash, plain) { | ||
"use strict"; | ||
return bindings.verifySync(encrypted, plain, /argon2d/.test(encrypted)); | ||
return bindings.verifySync(hash, plain, /argon2d/.test(hash)); | ||
}; | ||
{ | ||
"name": "argon2", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "An Argon2 library for Node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,4 +17,4 @@ # 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] | ||
argon2.encrypt('password', 'somesalt', function (err, hash) { | ||
if (err) // encryption failure | ||
argon2.hash('password', 'somesalt', function (err, hash) { | ||
if (err) // hashion failure | ||
throw err; | ||
@@ -28,3 +28,3 @@ | ||
try { | ||
var hash = argon2.encryptSync('password', 'somesalt'); | ||
var hash = argon2.hashSync('password', 'somesalt'); | ||
} catch (err) { | ||
@@ -40,3 +40,3 @@ console.log(err); | ||
argon2.encrypt('password', 'somesalt', { | ||
argon2.hash('password', 'somesalt', { | ||
argon2d: true | ||
@@ -50,3 +50,3 @@ }, function (err, hash) { | ||
try { | ||
var hash = argon2.encryptSync('password', 'somesalt', { | ||
var hash = argon2.hashSync('password', 'somesalt', { | ||
argon2d: true | ||
@@ -81,3 +81,3 @@ }); | ||
argon2.generateSalt(function (salt) { | ||
argon2.encrypt('password', salt, { | ||
argon2.hash('password', salt, { | ||
timeCost: 4, memoryCost: 13, parallelism: 2 | ||
@@ -91,3 +91,3 @@ }, function (err, hash) { | ||
var hash = argon2.encryptSync('password', argon2.generateSalt(), { | ||
var hash = argon2.hashSync('password', argon2.generateSalt(), { | ||
timeCost: 4, memoryCost: 13, parallelism: 2 | ||
@@ -94,0 +94,0 @@ }); |
@@ -25,3 +25,3 @@ var argon2 = process.env.COVERAGE | ||
argon2.encrypt("password", "somesalt", function (err, hash) { | ||
argon2.hash("password", "somesalt", function (err, hash) { | ||
assert.ok(hash, "Hash should be defined."); | ||
@@ -39,3 +39,3 @@ assert.equal(hash, "$argon2i$m=4096,t=3,p=1$c29tZXNhbHQAAAAAAAAAAA$FHF/OZ0GJpMRAlBmPTqXxw36Ftp87JllALZPcP9w9gs"); | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
argon2d: true | ||
@@ -55,3 +55,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
argon2d: "foo" | ||
@@ -71,3 +71,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
argon2d: "" | ||
@@ -87,3 +87,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesaltwaytoobig", function (err, hash) { | ||
argon2.hash("password", "somesaltwaytoobig", function (err, hash) { | ||
assert.ok(err, "Error should be defined."); | ||
@@ -101,3 +101,3 @@ assert.equal(err.message, "Salt too long, maximum 16 characters."); | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
timeCost: 4 | ||
@@ -117,3 +117,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
timeCost: "foo" | ||
@@ -133,3 +133,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
memoryCost: 13 | ||
@@ -149,3 +149,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
memoryCost: "foo" | ||
@@ -165,3 +165,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
memoryCost: 32 | ||
@@ -181,3 +181,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
parallelism: 2 | ||
@@ -197,3 +197,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
parallelism: "foo" | ||
@@ -213,3 +213,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", "somesalt", { | ||
argon2.hash("password", "somesalt", { | ||
timeCost: 4, | ||
@@ -231,3 +231,3 @@ memoryCost: 13, | ||
var hash = argon2.encryptSync("password", "somesalt"); | ||
var hash = argon2.hashSync("password", "somesalt"); | ||
assert.equal(hash, "$argon2i$m=4096,t=3,p=1$c29tZXNhbHQAAAAAAAAAAA$FHF/OZ0GJpMRAlBmPTqXxw36Ftp87JllALZPcP9w9gs"); | ||
@@ -242,3 +242,3 @@ assert.done(); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
argon2d: true | ||
@@ -255,3 +255,3 @@ }); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
argon2d: "foo" | ||
@@ -268,3 +268,3 @@ }); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
argon2d: "" | ||
@@ -281,3 +281,3 @@ }); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
timeCost: 4 | ||
@@ -295,3 +295,3 @@ }); | ||
assert.throws(function () { | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
timeCost: "foo" | ||
@@ -308,3 +308,3 @@ }); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
memoryCost: 13 | ||
@@ -322,3 +322,3 @@ }); | ||
assert.throws(function () { | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
memoryCost: "foo" | ||
@@ -336,3 +336,3 @@ }); | ||
assert.throws(function () { | ||
argon2.encryptSync("password", "somesalt", { | ||
argon2.hashSync("password", "somesalt", { | ||
memoryCost: 32 | ||
@@ -349,3 +349,3 @@ }); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
parallelism: 2 | ||
@@ -363,3 +363,3 @@ }); | ||
assert.throws(function () { | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
parallelism: "foo" | ||
@@ -376,3 +376,3 @@ }); | ||
var hash = argon2.encryptSync("password", "somesalt", { | ||
var hash = argon2.hashSync("password", "somesalt", { | ||
timeCost: 4, | ||
@@ -392,3 +392,3 @@ memoryCost: 13, | ||
assert.throws(function () { | ||
argon2.encryptSync("password", "somesaltwaytoobig"); | ||
argon2.hashSync("password", "somesaltwaytoobig"); | ||
}); | ||
@@ -423,3 +423,3 @@ assert.done(); | ||
argon2.verify(argon2.encryptSync("password", argon2.generateSaltSync()), | ||
argon2.verify(argon2.hashSync("password", argon2.generateSaltSync()), | ||
"password", function (err) { | ||
@@ -436,3 +436,3 @@ assert.equal(undefined, err); | ||
argon2.verify(argon2.encryptSync("password", argon2.generateSaltSync()), | ||
argon2.verify(argon2.hashSync("password", argon2.generateSaltSync()), | ||
"passwolrd", function (err) { | ||
@@ -449,3 +449,3 @@ assert.ok(err, "Error should be defined."); | ||
argon2.encrypt("password", argon2.generateSaltSync(), { | ||
argon2.hash("password", argon2.generateSaltSync(), { | ||
argon2d: true | ||
@@ -465,3 +465,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", argon2.generateSaltSync(), { | ||
argon2.hash("password", argon2.generateSaltSync(), { | ||
argon2d: true | ||
@@ -481,3 +481,3 @@ }, function (err, hash) { | ||
assert.equal(true, argon2.verifySync(argon2.encryptSync("password", | ||
assert.equal(true, argon2.verifySync(argon2.hashSync("password", | ||
argon2.generateSaltSync()), "password")); | ||
@@ -492,3 +492,3 @@ assert.done(); | ||
assert.equal(false, argon2.verifySync(argon2.encryptSync("password", | ||
assert.equal(false, argon2.verifySync(argon2.hashSync("password", | ||
argon2.generateSaltSync()), "passworld")); | ||
@@ -503,3 +503,3 @@ assert.done(); | ||
argon2.encrypt("password", argon2.generateSaltSync(), { | ||
argon2.hash("password", argon2.generateSaltSync(), { | ||
argon2d: true | ||
@@ -517,3 +517,3 @@ }, function (err, hash) { | ||
argon2.encrypt("password", argon2.generateSaltSync(), { | ||
argon2.hash("password", argon2.generateSaltSync(), { | ||
argon2d: true | ||
@@ -520,0 +520,0 @@ }, function (err, hash) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1463116