-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (32 loc) · 753 Bytes
/
index.js
File metadata and controls
39 lines (32 loc) · 753 Bytes
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
31
32
33
34
35
36
37
38
39
/*
- A module used to hash passwords
- Author : Alexandros Lemesios (alexlemesios@gmail.com)
*/
"use strict";
const prompt = require("prompt");
const bcrypt = require("bcryptjs");
prompt.start();
const schema = {
properties: {
password: {
hidden: true,
required: true
},
passwordVerification: {
hidden: true,
required: true
}
}
}
prompt.get(schema, function (err, result) {
if (result.password === result.passwordVerification) {
console.log("Passwords have matched !");
}
else {
console.log("Passwords didn't match , please try again");
return false;
}
const salt = bcrypt.genSaltSync(10);
const hash = bcrypt.hashSync(result.password, salt);
console.log(hash);
});