Last active
December 9, 2022 23:00
-
-
Save lnlyssg/966bf1bcc77d166f97263b61661d4526 to your computer and use it in GitHub Desktop.
Revisions
-
lnlyssg renamed this gist
Dec 9, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Jim created this gist
Mar 18, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ /* rexx ***************************************************************/ /* */ /* Purpose : Generate a random password. */ /* Author : Andrew Cameron-Heffer */ /* */ /* The REXX can be passed 2 values. */ /* (1) the number of passwords requested (default = 1) */ /* (2) length of each password (default = 8) */ /* */ /* Or, use PWGEN ? to get brief help. */ /* */ /* The password cannot be all upper-case, lower-case, mixed-case or */ /* numeric. National characters '£', '#' and '@' help this happen. */ /* */ /**********************************************************************/ /* receive parameters (count and length) */ /* if it's a number then use it */ /* if not then just set it to 1 */ arg count length . select when count = '' then count = 1 when count = '?' then do say "This REXX generates random passwords. It can be sent two" say "variables: COUNT LENGTH. Default to 1 8-character password." say "PWGEN 4 will generate 4 8-character passwords." say "PWGEN 1 16 will generate 1 16-character password." say "PWGEN 3 12 will generate 3 12-character password." say " " count = 0 end when count < 1 then count = 1 when datatype(count,'N') = 0 then count = 1 otherwise nop end select when length = '' then length = 8 when length < 2 then length = 2 otherwise nop end /* set random letters/numbers */ chars = "abcdefghijklmnopqrstuvwxyz0123456789£#@" || , "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789£#@" charc = length(chars) /* go round loop for required count */ /* get 8 characters for each password */ /* say the answer to the user */ do a = 1 to count reject = 1 do forever while reject newpw = '' do b = 1 to length num = random(1,charc) let = substr(chars,num,1) newpw = newpw || let end select when datatype(newpw,'N') then reject = 1 /* numeric only */ when datatype(newpw,'L') then reject = 1 /* lower case only */ when datatype(newpw,'M') then reject = 1 /* mixed case only */ when datatype(newpw,'U') then reject = 1 /* upper case only */ otherwise reject = 0 end end say newpw end exit 0