Files
hoerdle/scripts/hash-password.js

25 lines
796 B
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const bcrypt = require('bcryptjs');
const password = process.argv[2];
if (!password) {
console.error('Please provide a password to hash.');
console.error('Usage: node scripts/hash-password.js <password>');
process.exit(1);
}
const saltRounds = 10;
bcrypt.hash(password, saltRounds, (err, hash) => {
if (err) {
console.error('Error hashing password:', err);
return;
}
console.log('Plaintext:', password);
console.log('Bcrypt Hash:', hash);
console.log('\n⚠ IMPORTANT FOR DOCKER COMPOSE:');
console.log('If you use this hash directly in docker-compose.yml, you MUST escape the $ signs:');
console.log('Docker Hash:', hash.replace(/\$/g, '$$$$'));
console.log('\nSet this hash as your ADMIN_PASSWORD environment variable.');
});