added npm password_generator script

This commit is contained in:
WeeXnes 2025-02-28 02:25:26 +01:00
parent d04a25b0e0
commit f27c232090
3 changed files with 33 additions and 1 deletions

View 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);
});

View 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": ""
}

View file

@ -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",