-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_generator.vbs
More file actions
66 lines (55 loc) · 2.17 KB
/
password_generator.vbs
File metadata and controls
66 lines (55 loc) · 2.17 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
Const UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const LOWER_CASE = "abcdefghijklmnopqrstuvwxyz"
Const NUMBERS = "0123456789"
Const SYMBOLS = "!@#$%^&*()_+-={}[]|;:,.<>?/~`"
Dim intLength, strPassword, objShell, objFSO, objFile, objFolder, objButton
intLength = 12
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetSpecialFolder(2)
strTempPath = objFolder.Path & "\" & objFSO.GetTempName
objFSO.CreateFolder(strTempPath)
Set objFile = objFSO.CreateTextFile(strTempPath & "\password.html", True)
objFile.WriteLine "<html>"
objFile.WriteLine "<head>"
objFile.WriteLine "<style>"
objFile.WriteLine "body {"
objFile.WriteLine "background-color: #f0f0f0;"
objFile.WriteLine "font-family: Arial, sans-serif;"
objFile.WriteLine "margin: 0;"
objFile.WriteLine "padding: 0;"
objFile.WriteLine "}"
objFile.WriteLine ""
objFile.WriteLine "button {"
objFile.WriteLine "background-color: #007bff;"
objFile.WriteLine "border: none;"
objFile.WriteLine "border-radius: 5px;"
objFile.WriteLine "color: #fff;"
objFile.WriteLine "cursor: pointer;"
objFile.WriteLine "font-size: 16px;"
objFile.WriteLine "padding: 10px 20px;"
objFile.WriteLine "margin: 20px auto;"
objFile.WriteLine "display: block;"
objFile.WriteLine "}"
objFile.WriteLine "</style>"
objFile.WriteLine "</head>"
objFile.WriteLine "<body>"
objFile.WriteLine "<p id=""password"">" & GeneratePassword(UPPER_CASE & LOWER_CASE & NUMBERS & SYMBOLS, intLength) & "</p>"
objFile.WriteLine "<button onclick=""copyToClipboard()"">Copy Password</button>"
objFile.WriteLine "</body>"
objFile.WriteLine "</html>"
objFile.Close
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "iexplore.exe", strTempPath & "\password.html", "", "open", 1
Function GeneratePassword(strCharacters, intLength)
Dim intCounter, strPassword, strCharacter
For intCounter = 1 To intLength
strCharacter = Mid(strCharacters, Int((Len(strCharacters) + 1) * Rnd), 1)
strPassword = strPassword & strCharacter
Next
GeneratePassword = strPassword
End Function
' Clean up
Set objFSO = Nothing
Set objFile = Nothing
Set objFolder = Nothing
Set objShell = Nothing