init
This commit is contained in:
commit
90f54e3f73
17
.eslintrc.js
Normal file
17
.eslintrc.js
Normal 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
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/node_modules/
|
||||
/dist/
|
41
index.js
Normal file
41
index.js
Normal 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
20
package.json
Normal 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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user