Atualização para descriptografar hash

pull/21/head
adriano 2023-07-24 17:29:41 -03:00
parent 398a6be82b
commit 417f947263
2 changed files with 32 additions and 19 deletions

View File

@ -167,10 +167,23 @@ app.post('/api/session', async function (req, res) {
lstPass = lstPass.split(',') lstPass = lstPass.split(',')
let password = null let password = null
password = await lstPass.find( // password = await lstPass.find(
async (pass) => // async (pass) =>
await bcrypt.compare(pass.trim(), db_credentials.db_conf.DB_PASS) // await bcrypt.compare(pass.trim(), db_credentials.db_conf.DB_PASS)
) // )
for (let i = 0; i < lstPass.length; i++) {
const hasPass = await bcrypt.compare(
lstPass[i].trim(),
db_credentials.db_conf.DB_PASS
)
if (hasPass) {
password = lstPass[i].trim()
break
}
}
if (password) { if (password) {
db_credentials.db_conf.DB_PASS = password db_credentials.db_conf.DB_PASS = password
} else { } else {

View File

@ -1,20 +1,20 @@
const bcrypt = require('bcrypt') const bcrypt = require('bcrypt')
const pass = async () => { // const pass = async () => {
// create a password // // create a password
const salt = await bcrypt.genSalt(12) // const salt = await bcrypt.genSalt(12)
const passwordHash = await bcrypt.hash('strongpassword', salt) // const passwordHash = await bcrypt.hash('7901228899', salt)
console.log(passwordHash) // console.log(passwordHash)
}
pass()
// const passDec = async () => {
// const _pass = await bcrypt.compare(
// 'strongpassword',
// '$2b$12$R/bpS7b9FzdXlHAijmP.3.gJqgeUjwQVSuK6q.G0PZbb0wowCnrN.'
// )
// console.log('_pass: ', _pass)
// } // }
// passDec() // pass()
const passDec = async () => {
const _pass = await bcrypt.compare(
'strongpassword',
'$2b$12$PZ8N1jU77nnNUCCGyKTMNOi2QI7X/SgPsISVQfr.cQ/jgdx5Z7AqC'
)
console.log('_pass: ', _pass)
}
passDec()
console.log('process.cwd(): ', process.cwd()) console.log('process.cwd(): ', process.cwd())