This commit is contained in:
Timo Hocker 2020-03-04 12:20:42 +01:00
commit 90f54e3f73
6 changed files with 3543 additions and 0 deletions

17
.eslintrc.js Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true
},
extends: [
'@scode'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018
}
}

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/node_modules/
/dist/

1
.npmrc Normal file
View File

@ -0,0 +1 @@
@scode:registry=https://npm.scode.ovh

41
index.js Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright (C) Sapphirecode - All Rights Reserved
* Created by Timo Hocker <timo@scode.ovh>, March 2020
*/
/* eslint-disable no-magic-numbers */
'use strict';
const argon2 = require('argon2');
const argon_options = {
hashLength: 64,
saltLength: 32,
type: argon2.argon2id
};
/**
* verify a plain text against an argon2 hash
*
* @param {string} hash argon hash
* @param {string} plain plain text
* @returns {Promise<boolean>} true if valid
*/
function argon_verify (hash, plain) {
return argon2.verify (hash, plain, argon_options);
}
/**
* create an argon2 hash
*
* @param {string} plain plain text
* @returns {Promise<string>} hash
*/
function argon_hash (plain) {
return argon2.hash (plain, argon_options);
}
module.exports = {
argon_hash,
argon_verify
}

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "@scode/password-helper",
"version": "1.0.0",
"main": "index.js",
"author": "Timo Hocker <t-hocker@web.de>",
"license": "MIT",
"devDependencies": {
"@scode/eslint-config": "^1.2.25",
"ava": "^3.5.0",
"eslint": "^6.8.0",
"nyc": "^15.0.0"
},
"scripts": {
"lint": "eslint .",
"test": "nyc ava"
},
"dependencies": {
"argon2": "^0.26.1"
}
}

3462
yarn.lock Normal file

File diff suppressed because it is too large Load Diff