homelab-dashboard/scripts/generate-password-hash.js
Bilal Teke 69c2057252 v4
2026-04-20 14:34:07 +02:00

31 lines
771 B
JavaScript

#!/usr/bin/env node
/**
* Generate a bcryptjs hash for a password.
* Used to create ADMIN_PASSWORD_HASH for environment configuration.
*
* Usage: node scripts/generate-password-hash.js
*/
const bcryptjs = require('bcryptjs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter the password to hash: ', (password) => {
if (!password) {
console.error('Error: Password cannot be empty');
rl.close();
process.exit(1);
}
const hash = bcryptjs.hashSync(password, 10);
console.log('\n✓ Password hash generated successfully:\n');
console.log(hash);
console.log('\nAdd this value to your .env file as ADMIN_PASSWORD_HASH\n');
rl.close();
});