1
0

Video 106: JSON Web Tokens

This commit is contained in:
JayWll
2020-04-13 15:55:29 -06:00
parent 6a7cb2882f
commit fed44eda88
3 changed files with 96 additions and 8 deletions

View File

@@ -14,17 +14,14 @@ app.listen(port, () => {
console.log('Server is up on port ' + port)
})
const bcrypt = require('bcryptjs')
const jwt = require('jsonwebtoken')
const myFunction = async () => {
const password = 'Red12345!'
const hashedPassword = await bcrypt.hash(password, 8)
const token = jwt.sign({ _id: 'abc123' }, 'thisismynewcourse', { expiresIn: '7 days' })
console.log(token)
console.log(password)
console.log(hashedPassword)
const isMatch = await bcrypt.compare('red12345!', hashedPassword)
console.log(isMatch)
const data = jwt.verify(token, 'thisismynewcourse')
console.log(data)
}
myFunction()