-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash.js
30 lines (24 loc) · 846 Bytes
/
hash.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const bcrypt = require('bcrypt') // return object
function run(){
async function hash(){
const salt = await bcrypt.genSalt(10)
const hashedPassword = await bcrypt.hash('1234', salt)
console.log(`Salt: ${salt}`)
console.log(`Hashed Password: ${hashedPassword}\n`)
}
async function countSaltCharacters(){
const salt = await bcrypt.genSalt(10000000000000000000000)
console.log(`Salt: ${salt}`)
console.log(`Salt Length: ${salt.length}`)
}
async function validate(password){
const salt = await bcrypt.genSalt(10)
const mypassword = '2342'
const hash = await bcrypt.hash(mypassword, salt)
const isValid = await bcrypt.compare(password, hash)
console.log(isValid)
}
// countSaltCharacters()
validate('2341')
}
run()