added npm password_generator script
This commit is contained in:
parent
d04a25b0e0
commit
f27c232090
3 changed files with 33 additions and 1 deletions
20
.password_hash_gen/generator.js
Normal file
20
.password_hash_gen/generator.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
const bcrypt = require('bcryptjs');
|
||||
|
||||
// Get the password from the command-line arguments
|
||||
const password = process.argv[2];
|
||||
|
||||
if (!password) {
|
||||
console.log('Please provide a password as a command-line argument.');
|
||||
process.exit(1); // Exit the program if no password is provided
|
||||
}
|
||||
|
||||
const saltRounds = 10;
|
||||
|
||||
// Generate bcrypt hash asynchronously
|
||||
bcrypt.hash(password, saltRounds)
|
||||
.then(hash => {
|
||||
console.log('Generated bcrypt hash:', hash);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Error generating hash:', err);
|
||||
});
|
11
.password_hash_gen/package.json
Normal file
11
.password_hash_gen/package.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "password_hash_gen",
|
||||
"version": "1.0.0",
|
||||
"main": "generator.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": ""
|
||||
}
|
|
@ -7,7 +7,8 @@
|
|||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
"postinstall": "nuxt prepare",
|
||||
"password_generator": "node .password_hash_gen/generator.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt": "^3.15.4",
|
||||
|
|
Loading…
Add table
Reference in a new issue