-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyGen.js
44 lines (37 loc) · 1.25 KB
/
keyGen.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
function genKey(length = 200) {
const CHAR =
"abcdefghijklmnopqrstuvwxyzABCDEFGHUJKLMNOPQRSTUVWXYZ!@#$%^&*()_+=0123456789/|-`',.?";
let key = "";
for (let i = 0; i < length; i++) {
const index = Math.floor(Math.random() * 83);
key = key + CHAR[index];
}
console.log("\nKey generated :");
return key;
}
console.log(" _ __ _______ _______ ");
console.log("| | / / | _____\\ / ______\\ ");
console.log("| | / / | |_____ / / ___ ");
console.log("| | / / | _____\\ / / / _ \\ ");
console.log("| | \\ \\ | | \\ \\ \\/ \\ \\");
console.log("| | \\ \\ | |______ \\ \\_____/ /");
console.log("|_| \\_\\ |_______/ \\_______/ ");
console.log("\nBuild Your Secret Key Easily");
rl.question("\n? How many character should have your key? ", function (length) {
const pattern = /^[0-9]{0,}$/g;
const valid = length.match(pattern);
if (length !== "" && valid !== null) {
console.log(genKey(+valid[0]));
console.log("\nEnjoy it!");
rl.close();
} else {
console.log("\n\n you should enter a number!!");
rl.close();
}
});
rl.on("close", () => process.exit(0));