RosettaCodeData/Task/Password-generator/Commodore-BASIC/password-generator.basic
2023-07-01 13:44:08 -04:00

63 lines
2.1 KiB
Text

1 rem password generator
2 rem rosetta code
10 g$(1)="abcdefghijklmnopqrstuvwxyz"
15 g$(2)="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
20 g$(3)="0123456789"
25 g$(4)="<>!@#$%^&*()[];:'.?/"
30 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 get k$:if k$="" then 45
50 if k$="h" then gosub 500
60 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$(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 goto 110
150 next i
155 pw$(pc)=tp$
160 next pc
200 print chr$(147);"Password list:":print
205 for pc=1 to np:print pc;chr$(157);".";tab(6);pw$(pc):next pc
210 print:print "Again? (y/n)";
215 get k$:if k$<>"y" and k$<>"n" then 215
220 if k$="y" then clr:goto 10
225 end
500 rem *** help ***
505 print chr$(147);"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 get k$:if k$="" then 615
620 return