71 lines
2.4 KiB
Text
71 lines
2.4 KiB
Text
MODULE PASSWORD_CREATOR {
|
|
1 rem password generator
|
|
2 rem rosetta code
|
|
3 dim g$(1 to 4), pw$(1 to 10), g(1 to 10)
|
|
4 def tab(x)=string$(" ", max.data(pos, x-1)-pos)
|
|
5 def rnd(x)=rnd*x
|
|
6 rem from COMMODORE BASIC
|
|
7 Form 40, 25
|
|
10 g$(1)="abcdefghijklmnopqrstuvwxyz"
|
|
15 g$(2)="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
20 g$(3)="0123456789"
|
|
25 g$(4)="<>!@#$%^&*()[];:'.?/"
|
|
30 CLS ' print chr$(147);chr$(14)
|
|
35 print "Password Generator":print
|
|
40 print "Press H for help, or any":print "other key to begin.":print
|
|
45 k$=inkey$:if k$="" then 45
|
|
50 if k$="h" or k$="H" then gosub 500
|
|
60 CLS ' print chr$(147)
|
|
65 input "Enter password length: (6-30):";pl
|
|
70 if pl<6 or pl>30 then print "Out of range.":goto 65
|
|
75 print:input "How many passwords (1-20):";np
|
|
80 if np<1 or np>20 then print "Out of range.":goto 75
|
|
85 if np>10 then dim pw$(1 to np)
|
|
90 if np*pl > 100 then print:print "Um... Ok, this might take a bit."
|
|
100 for pc=1 to np
|
|
105 for i=1 to 4:g(i)=0:next
|
|
110 tp$=""
|
|
112 for i=1 to pl
|
|
115 cg=int(rnd(1)*4)+1
|
|
120 cc=int(rnd(1)*len(g$(cg)))+1
|
|
125 tp$=tp$+mid$(g$(cg),cc,1)
|
|
130 g(cg)=g(cg)+1
|
|
135 next i
|
|
140 for i=1 to 4
|
|
145 if g(i)=0 then exit for 110
|
|
150 next i
|
|
155 pw$(pc)=tp$
|
|
160 next pc
|
|
200 CLS: print "Password list:":print
|
|
205 for pc=1 to np:print pc;".";tab(6);pw$(pc):next pc
|
|
210 print:print "Again? (y/n)";
|
|
215 k$=inkey$:if k$<>"y" and k$<>"n" and k$<>"Y" and k$<>"N" then 215
|
|
220 if k$="y" or k$="Y" then clear:goto 1
|
|
225 end
|
|
500 rem *** help ***
|
|
505 CLS: print "This program will generate a password"
|
|
510 print "made up of each of the following"
|
|
515 print "character types:":print
|
|
520 print " - Uppercase Letter (A-Z)"
|
|
525 print " - Lowercase Letter (a-z)"
|
|
530 print " - Number (0-9)"
|
|
535 print " - Punctuation and Other Symbols"
|
|
540 print " (e.g. # $ ! & [ . ;, etc.)"
|
|
545 print
|
|
550 print "You may choose how many total characters";
|
|
555 print "(up to 30) should be in the password, "
|
|
560 print "and how many passwords (up to 20) should";
|
|
565 print "be generated. The program ensures that "
|
|
570 print "there is at least one character from "
|
|
575 print "each of the character types in each "
|
|
580 print "password."
|
|
585 print
|
|
590 print "Note: You can edit the character lists"
|
|
595 print "on lines 10-25 to customize the"
|
|
600 print "selection pool."
|
|
605 print
|
|
610 print "Press any key to begin."
|
|
615 k$=inkey$:if k$="" then 615
|
|
620 return
|
|
}
|
|
PASSWORD_CREATOR
|