Create a password generation program which will generate passwords containing random ASCII characters from the following groups:

         lower-case letters:  a ──► z
         upper-case letters:  A ──► Z
                     digits:  0 ──► 9
 other printable characters:  !"#$%&'()*+,-./:;<=>?@[]^_{|}~ 
 (the above character list excludes white-space, backslash and grave) 



The generated password(s) must include   at least one   (of each of the four groups):

   lower-case letter, 
   upper-case letter,
   digit  (numeral),   and 
   one  "other"  character. 



The user must be able to specify the password length and the number of passwords to generate.

The passwords should be displayed or written to a file, one per line.

The randomness should be from a system source or library.

The program should implement a help option or button which should describe the program and options when invoked.

You may also allow the user to specify a seed value, and give the option of excluding visually similar characters.

For example:            Il1     O0     5S     2Z            where the characters are:

   capital eye, lowercase ell, the digit one
   capital oh, the digit zero 
   the digit five, capital ess
   the digit two, capital zee


1 N=1
2 L=8
3 M$=CHR$(13)
4 D$=CHR$(4)
5 S$(0)="S"
6 F$="A FILE"
7 C$(1)=" (CURRENT OPTION)"
8 DEF FN R(T)=ASC(MID$(G$(T),INT(RND(1)*LEN(G$(T))+1),1))
9 GOSUB 750
10 FOR Q = 0 TO 1 STEP 0
20     GOSUB 50CHOOSE
30 NEXT Q
40 END
 
REM *** CHOOSE ***
50 PRINT M$M$"1 GEN 2 DISP 3 FILE 4 LEN 5 NUM 6 SEED"
60 PRINT "7 CHR 8 HELP 9 QUIT "CHR$(10)"CHOOSE AN OPTION: ";
70 GET K$
75 IF K$ > CHR$(95) THEN K$ = CHR$(ASC(K$) - 32)
80 PRINT K$
85 ON VAL(K$) GOTO 100,200,300,400,500,600,700,800,900
90 GOTO 210OPTIONS
 
REM *** GENERATE ***
100 PRINT M$ 
105 IF L > 32 THEN PRINT "UM... OK, THIS MIGHT TAKE A BIT."M$
110 GOSUB 340OPEN
115 FOR P=1 TO N
120     P$=""
125     FOR I=1 TO L
135         P$=P$+CHR$(FNR(I*(I<5)))
140     NEXT I
REM     SHUFFLE FIRST 4
150     FOR I = 1 TO 4
151         C$=MID$(P$,I,1)
152         J=INT(RND(1)*L)+1
153         H$=MID$(P$,J,1)
154         P$=MID$(P$,1,J-1)+C$+MID$(P$,J+1,L)
155         P$=MID$(P$,1,I-1)+H$+MID$(P$,I+1,L)
156     NEXT I
180     PRINT P$
185 NEXT P
190 GOTO 380CLOSE
 
REM *** DISPLAY ***
200 C = 0
REM *** OPTIONS ***
210 HOME
215 PRINT "PASSWORD GENERATOR"M$M$
220 PRINT "1.  GENERATE "N" PASSWORD"S$(N=1)M$
225 PRINT "2.  DISPLAYED"C$(C=0)M$"       OR"
230 PRINT "3.  WRITTEN TO "F$C$(C=1)M$
235 PRINT "4.  SPECIFY THE PASSWORD LENGTH = "L;M$
240 PRINT "5.  SPECIFY THE NUMBER OF PASSWORDS TO"M$TAB(31)"GENERATE"
245 PRINT "6.  SPECIFY A SEED VALUE"M$
250 PRINT "7.  EXCLUDE VISUALLY SIMILAR CHARACTERS"M$
255 PRINT "8.  HELP AND OPTIONS"
260 RETURN
 
REM *** WRITE TO A FILE ***
300 C = 1
310 GOTO 210OPTIONS
REM *** OPEN A FILE ***
340 IF NOT C THEN RETURN
345 PRINT D$"OPEN "F$"
350 PRINT D$"CLOSE"F$
355 PRINT D$"DELETE "F$
360 PRINT D$"OPEN "F$
365 PRINT D$"WRITE "F$
370 RETURN
REM *** CLOSE A FILE ***
380 IF NOT C THEN RETURN
385 PRINT D$"CLOSE"F$
390 RETURN
 
REM *** SET PASSWORD LENGTH ***
400 PRINT M$
410 FOR I = 0 TO 1 STEP 0
420 INPUT "ENTER A NUMBER FROM 4 TO 255 TO SPECIFY THE PASSWORD LENGTH = ";L
430 IF L >= 4 AND L < 256 THEN RETURN
440 PRINT "?OUT OF RANGE"
450 NEXT I
 
REM *** SET NUMBER OF PASSWORDS TO GENERATE ***
500 PRINT M$
510 FOR I = 0 TO 1 STEP 0
520 INPUT "ENTER A NUMBER FROM 1 AND UP TO SPECIFY THE NUMBER OF PASSWORDS TO GENERATE: ";N
530 IF N >= 1 THEN RETURN
540 PRINT "?OUT OF RANGE."
550 NEXT I
 
REM *** SET A SEED VALUE ***
600 PRINT M$
610 INPUT "ENTER A SEED VALUE: ";S%
620 PRINT RND(S%)
630 RETURN
 
REM *** EXCLUDE ***
700 PRINT M$
705 INPUT "ENTER CHARACTERS TO EXCLUDE:";E$
REM *** GROUPS ***
REM ALWAYS EXCLUDE BACKSLASH AND BACKTICK (GRAVE)
710 E$=CHR$(92)+CHR$(96)+E$
711 FOR G = 1 TO 4
712     G$(G) = ""
713 NEXT G
720 FOR G = 1 TO 2
721     FOR K = ASC("A") + (G - 1) * 32 TO ASC("Z") + (G - 1) * 32
722         GOSUB 770ADD
723 NEXT K, G
730 FOR K = 33 TO 64
731     G = 3 + (K < ASC(STR$(0)) OR K > ASC(STR$(9)))
732     GOSUB 770ADD
733 NEXT K
734 FOR K = 91 TO 96
735     GOSUB 770ADD
736 NEXT K
737 FOR K = 123 TO 126
738     GOSUB 770ADD
739 NEXT K
740 G$(0) = ""
741 FOR G = 1 TO 4
742     IF LEN(G$(G)) THEN G$(0) = G$(0) + G$(G) : NEXT G : GOTO 800HELP
743 ?"THERE MUST BE AT LEAST ONE CHARUNRACTER IN EACH GROUP"
744 GOTO 705
REM *** DEFAULT (QUICK) ***
750 G$(1)="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
751 FOR I=97TO122:G$(2)=G$(2)+CHR$(I):NEXT
753 G$(3)="0123456789"
754 G$(4)="!"+CHR$(34)+"#$%&'()*+,-./:;<=>?@"+CHR$(91)+"]^"+CHR$(95)
755 FOR I=123TO126:G$(4)=G$(4)+CHR$(I):NEXTI
756 G$(0)=G$(0)+G$(1)+G$(2)+G$(3)
757 GOTO 210OPTIONS
REM *** ADD TO GROUP
770 C$ = CHR$(K)
775 FOR E = 1 TO LEN(E$)       
780         IF C$ <> MID$(E$,E,1) THEN NEXT E : G$(G)=G$(G)+C$ : ?C$;
790 RETURN
 
REM *** HELP ***
800 HOME
805 PRINT "GENERATE PASSWORDS CONTAINING RANDOM"
810 PRINT "ASCII CHARACTERS FROM THESE GROUPS:"M$
815 PRINT "  LOWERCASE UPPERCASE DIGIT OTHER"M$
820 PRINT "  "LEFT$(G$(2),9)TAB(13)LEFT$(G$(1),9)TAB(23)LEFT$(G$(3),5)TAB(29)LEFT$(G$(4),11)
825 PRINT "  "MID$(G$(2),10,9)TAB(13)MID$(G$(1),10,9)TAB(23)MID$(G$(3),6,5)TAB(29)MID$(G$(4),12,11)
826 PRINT "  "MID$(G$(2),19,9)TAB(13)MID$(G$(1),19,9)TAB(29)MID$(G$(4),23,15)M$
840 PRINT "YOU MAY CHOOSE THE PASSWORD LENGTH, AND"
845 PRINT "HOW MANY PASSWORDS TO GENERATE. IT IS"
850 PRINT "ENSURED THAT THERE IS AT LEAST ONE"
855 PRINT "CHARACTER FROM EACH OF THE GROUPS IN"
860 PRINT "EACH PASSWORD. THERE IS AN OPTION TO"
865 PRINT "EXCLUDE VISUALLY SIMILAR CHARACTERS."
870 RETURN
 
REM *** QUIT ***
900 Q = 1
910 VTAB 23
920 RETURN