Code:
REM *************************************************** ' REM * Password generation program. * ' REM * * ' REM * I got tired of trying to come up with different * ' REM * passwords, so I wrote this program. * ' REM * * ' REM * Written in CC 5.01 * ' REM *************************************************** ' REM * * ' REM * Selection: 1 = Letters only * ' REM * 2 = Numbers only * ' REM * 3 = Mix-N-Match letters/numbers * ' REM * * ' REM * MinLen = Minimum string length * ' REM * MaxLen = Mazimum string length * ' REM * * ' REM *************************************************** ' REM * * ' REM * All you have to remember is the seed number and * ' REM * which password is associated with what web page * ' REM * you are accessing. * ' REM * * ' REM * The SEED number is entered only once when the * ' REM * program is run. The random number generator is * ' REM * reseeded with the same seed number each time a * ' REM * new password is requested. * ' REM * * ' REM *************************************************** ' ' #BREAK ON ' #INCLUDE "WIN32API.INC" ' GLOBAL MinLen, MaxLen, Selection AS LONG ' GLOBAL Seed, Which AS LONG ' ' FUNCTION PBMAIN ' LOCAL x, row AS LONG ' COLOR 14,1 ' CONSOLE SET SCREEN 10,50 ' ShowWindow CONSHNDL, %SW_MAXIMIZE ' Automatically maximize window ' LOCATE 3,5 ' INPUT "Enter the seed number: ",te$ ' IF te$ = "" THEN EXIT FUNCTION ' seed = VAL(te$) ' ' MinLen = 12 ' Make these user adjustable MaxLen = 12 ' later on? Selection = 3 ' ' DO '<-: For more than one password CLS ' | LOCATE 3,5 ' | INPUT "Which password would you like to use: ",te$ ' | IF te$ = "" THEN EXIT FUNCTION ' | Which = VAL(te$) ' | RANDOMIZE seed ' | ' | FOR x = 1 TO Which - 1 ' | PassWord$ = GeneratePassWord ' | NEXT x ' | ' | CLS ' | LOCATE 2,5 : PRINT;"Your password is: ";PassWord$ ' | LOCATE 5,3 : PRINT;"ESCape to end" ' | LOCATE 6,3 : PRINT;"SPACE for another password." ' | LOCATE 7,3 : PRINT;"ENTER to copy password to clipboard." ' | DO '<:| an$ = INKEY$ ' || IF an$ = CHR$(27) THEN EXIT FUNCTION ' || End the program IF an$ = CHR$(32) THEN EXIT LOOP ' || Go back for another IF an$ = CHR$(13) THEN ' || CALL copytoclipboard(PassWord$) ' || LOCATE 8,3 : PRINT;"Copied"; ' || END IF ' || LOOP '<:| LOOP '<-: ' END FUNCTION ' ' FUNCTION GeneratePassWord AS STRING ' LOCAL k, x AS LONG ' k = RND(MinLen, MaxLen) ' s1$ = "abcdefghijklmnopqrstuvwxyz" ' Letters only s2$ = "0123456789" ' Numbers only s3$ = "a0b1c2d3e4f5g6h7i8j9klmnopqrstuvwxyz" ' Mix-n-Match ' te$ = "" ' DO UNTIL LEN(te$) = k ' ' IF selection = 1 THEN '<: Letters only x = RND(1,LEN(s1$)) ' | te$ = te$ + MID$(s1$,x,1) ' | END IF '<: ' IF selection = 2 THEN '<: Numbers only x = RND(1,LEN(s2$)) ' | te$ = te$ + MID$(s2$,x,1) ' | END IF '<: ' IF selection = 3 THEN '<: Mix-N-Match x = RND(1,LEN(s3$)) ' | te$ = te$ + MID$(s3$,x,1) ' | END IF '<: ' LOOP ' FUNCTION = LCASE$(te$) ' Most of the time, it's ' lower case only, so... END FUNCTION ' ' ' Copy password to clipboard ' ' From Chris Boss at: ' ' http://www.powerbasic.com/support/pbforums/showthread.php?t=18342 ' Much obligated ' ' SUB CopyToClipboard(BYVAL Txt$) ' LOCAL hClip AS LONG, lpAddress AS LONG ' Txt$=Txt$+CHR$(0) ' hClip=GlobalAlloc(%GMEM_MOVEABLE, LEN(Txt$)) ' lpAddress=GlobalLock(hClip) ' POKE$ lpAddress, Txt$ ' GlobalUnlock hClip ' IF OpenClipboard(%NULL) THEN ' EmptyClipboard ' SetClipboardData %CF_TEXT, hClip ' CloseClipboard ' ELSE ' GlobalFree hClip ' END IF ' END SUB '
Comment