From 015ea3619f89abc2062c879edbcdd3fa42a1d71c Mon Sep 17 00:00:00 2001 From: JayWll Date: Mon, 13 Apr 2020 14:59:41 -0600 Subject: [PATCH] Video 103: Securely Storing Password: Part 1 --- task-manager/package-lock.json | 5 +++++ task-manager/package.json | 1 + task-manager/src/index.js | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/task-manager/package-lock.json b/task-manager/package-lock.json index 58fa238..41ea79b 100644 --- a/task-manager/package-lock.json +++ b/task-manager/package-lock.json @@ -180,6 +180,11 @@ } } }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=" + }, "binary-extensions": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", diff --git a/task-manager/package.json b/task-manager/package.json index 65bb30e..2ea991e 100644 --- a/task-manager/package.json +++ b/task-manager/package.json @@ -11,6 +11,7 @@ "author": "", "license": "ISC", "dependencies": { + "bcryptjs": "^2.4.3", "express": "^4.16.4", "mongodb": "^3.1.10", "mongoose": "^5.3.16", diff --git a/task-manager/src/index.js b/task-manager/src/index.js index cb544fa..59fd217 100644 --- a/task-manager/src/index.js +++ b/task-manager/src/index.js @@ -13,3 +13,18 @@ app.use(taskRouter) app.listen(port, () => { console.log('Server is up on port ' + port) }) + +const bcrypt = require('bcryptjs') + +const myFunction = async () => { + const password = 'Red12345!' + const hashedPassword = await bcrypt.hash(password, 8) + + console.log(password) + console.log(hashedPassword) + + const isMatch = await bcrypt.compare('red12345!', hashedPassword) + console.log(isMatch) +} + +myFunction()