-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
86 lines (61 loc) · 2.34 KB
/
script.js
File metadata and controls
86 lines (61 loc) · 2.34 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function copy() {
/* Get the text field */
var copyText = document.getElementById("pass-el-1");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
/* Copy the text inside the text field */
navigator.clipboard.writeText(copyText.value);
/* Alert the copied text */
// alert("Copied the text: " + copyText.value);
}
function generator() {
// Defining Variable
let dictionary = ["A", "B", "C", "D", "E", "1", "2", "3", "4", "5", "+", "$", "!", "a", "b", "c", "d", "e"]
let pass_length = 15
// -------Getting the Value-------->>
var Value = document.getElementById("input").value
console.log(Value)
if (Value) {
pass_length = Value
}
// Defining Elements
let passOne_El = document.getElementById("pass-el-1")
let passTwo_El = document.getElementById("pass-el-2")
let passThree_El = document.getElementById("pass-el-3")
let passFour_El = document.getElementById("pass-el-4")
// Empty Strings to pass strings from Dictionary one by one to
let passwordOne = ""
let passwordTwo = ""
let passwordThree = ""
let passwordFour = ""
// Loop to Generat random numbers for Passwords
for (let i = 0; i < pass_length; i++) {
// Randon Numbers from Dictionary
let num1 = dictionary[Math.floor(Math.random() * dictionary.length)]
let num2 = dictionary[Math.floor(Math.random() * dictionary.length)]
let num3 = dictionary[Math.floor(Math.random() * dictionary.length)]
let num4 = dictionary[Math.floor(Math.random() * dictionary.length)]
// Adding Numbers one by one to a single String
passwordOne += num1
passwordTwo += num2
passwordThree += num3
passwordFour += num4
}
// console.log(passOne_El)
// console.log(passTwo_El)
// console.log(passThree_El)
// console.log(passFour_El)
passOne_El.value = passwordOne
passTwo_El.textContent = passwordTwo
passThree_El.textContent = passwordThree
passFour_El.textContent = passwordFour
// console.log(passOne_El)
// console.log(passTwo_El)
// console.log(passThree_El)
// console.log(passFour_El)
// console.log(passwordOne)
// console.log(passwordTwo)
// console.log(passwordThree)
// console.log(passwordFour)
}