How to resolve the algorithm Password generator step by step in the Commodore BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Password generator step by step in the Commodore BASIC programming language

Table of Contents

Problem Statement

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

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

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:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Password generator step by step in the Commodore BASIC programming language

Source code in the commodore programming language

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

  

You may also check:How to resolve the algorithm String concatenation step by step in the UnixPipes programming language
You may also check:How to resolve the algorithm Factorial step by step in the Jsish programming language
You may also check:How to resolve the algorithm String append step by step in the Haskell programming language
You may also check:How to resolve the algorithm Regular expressions step by step in the ABAP programming language
You may also check:How to resolve the algorithm Ordered words step by step in the V (Vlang) programming language