You start the program, it asks for the amount of passwords you want to create and the length of the passwords, then they are saved in a text file called Passwords.txt
I have tested the program with 1 million passwords that has a length of 10 characters on my laptop and it took less then 2 seconds to create the passwords file.
Anyways, here's the code:
Code: Select all
;
; Simple password generator written by GeoTrail <geotrail@gmail.com>
;
Declare.s PasswordGenerator(Length.l)
PassFilename$ = "Passwords.txt"
NoOfPwd.l = Val(InputRequester("Password Generator", "Enter number of passwords to create:", Str(1000)))
PwdLen.l = Val(InputRequester("Password Generator", "Enter length of passwords to create:", Str(10)))
If NoOfPwd >= 1 And PwdLen >= 1
If FileSize(PassFilename$) = -1
OverWrite:
If CreateFile(0, PassFilename$)
For c=1 To NoOfPwd
WriteStringN(0, PasswordGenerator(PwdLen))
Next
CloseFile(0)
MessageRequester("Finished", "Successfully created file named " + Chr(34) + PassFilename$ + Chr(34) + Chr(13) + "containing "+Str(NoOfPwd)+" passwords with a length of "+Str(PwdLen)+" characters." + Chr(13) + Chr(13) + "This small util was written by GeoTrail.no")
EndIf
Else
If MessageRequester("File exist", "A password file already exists, do you want to overwrite it?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
Goto OverWrite
EndIf
EndIf
Else
MessageRequester("Error", "You must enter at least 1 on both requests.")
EndIf
;
End
Procedure.s PasswordGenerator(Length.l)
For x=1 To Length
i = Random(62)
Select i
Case 1
String$ + "a"
Case 2
String$ + "b"
Case 3
String$ + "c"
Case 4
String$ + "d"
Case 5
String$ + "e"
Case 6
String$ + "f"
Case 7
String$ + "g"
Case 8
String$ + "h"
Case 9
String$ + "i"
Case 10
String$ + "j"
Case 11
String$ + "k"
Case 12
String$ + "l"
Case 13
String$ + "m"
Case 14
String$ + "n"
Case 15
String$ + "o"
Case 16
String$ + "p"
Case 17
String$ + "q"
Case 18
String$ + "r"
Case 19
String$ + "s"
Case 20
String$ + "t"
Case 21
String$ + "u"
Case 22
String$ + "v"
Case 23
String$ + "w"
Case 24
String$ + "x"
Case 25
String$ + "y"
Case 26
String$ + "z"
Case 27
String$ + "A"
Case 28
String$ + "B"
Case 29
String$ + "C"
Case 30
String$ + "D"
Case 31
String$ + "E"
Case 32
String$ + "F"
Case 33
String$ + "G"
Case 34
String$ + "H"
Case 35
String$ + "I"
Case 36
String$ + "J"
Case 37
String$ + "K"
Case 38
String$ + "L"
Case 39
String$ + "M"
Case 40
String$ + "N"
Case 41
String$ + "O"
Case 42
String$ + "P"
Case 43
String$ + "Q"
Case 44
String$ + "R"
Case 45
String$ + "S"
Case 46
String$ + "T"
Case 47
String$ + "U"
Case 48
String$ + "V"
Case 49
String$ + "W"
Case 50
String$ + "X"
Case 51
String$ + "Y"
Case 52
String$ + "Z"
Case 53
String$ + "0"
Case 54
String$ + "1"
Case 55
String$ + "2"
Case 56
String$ + "3"
Case 57
String$ + "4"
Case 58
String$ + "5"
Case 59
String$ + "6"
Case 60
String$ + "7"
Case 61
String$ + "8"
Case 62
String$ + "9"
EndSelect
Next
ProcedureReturn String$
EndProcedure