const bcrypt = require('bcryptjs'); const fs = require('fs'); const password = 'Ba12sti34+'; bcrypt.hash(password, 10).then(hash => { console.log('Generated hash:', hash); // Test it immediately bcrypt.compare(password, hash).then(match => { console.log('Immediate verification:', match); // Write to .env.local const envContent = '# JWT Authentication\nJWT_SECRET=4916c430ed2682c2f023762e47531d95c6e51c4c5ab4ca8af79f6f010e203cf9\n\n# Admin Credentials\nADMIN_USERNAME=admin\nADMIN_PASSWORD_HASH=' + hash + '\n'; fs.writeFileSync('.env.local', envContent); console.log('.env.local written'); // Read it back and verify const readBack = fs.readFileSync('.env.local', 'utf8'); const hashMatch = readBack.match(/ADMIN_PASSWORD_HASH=(.*)/); if (hashMatch) { const storedHash = hashMatch[1].trim(); console.log('Stored hash:', storedHash); bcrypt.compare(password, storedHash).then(finalMatch => { console.log('Final verification from file:', finalMatch); }); } }); });