Merge pull request #12666 from smiddy007/improve-insufficient-pw-hash-query

JS: Improve insufficient pw hash query
This commit is contained in:
Asger F
2023-03-31 11:58:41 +02:00
committed by GitHub
6 changed files with 94 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
const crypto = require('crypto-js')
function hashPassword(email, password) {
var algo = crypto.algo.SHA512.create()
algo.update(password, 'utf-8') // BAD
algo.update(email.toLowerCase(), 'utf-8')
var hash = algo.finalize()
return hash.toString(crypto.enc.Base64)
}

View File

@@ -0,0 +1,8 @@
const crypto = require('crypto-js')
function hashPassword(email, password) {
var algo = crypto.algo.PBKDF2.create()
algo.update(password, 'utf-8') // GOOD
algo.update(email.toLowerCase(), 'utf-8')
var hash = algo.finalize()
return hash.toString(crypto.enc.Base64)
}