I'm trying to write a Windows batch file that will generate a random number from 0 to 9 and then load a different map list in our game server based on the random number. I am wanting to create a password generator which uses a list of pre-generated passwords using batch. The following script I am trying to adapt. I want the system to automatically generate a password using the prefix LONDON Also I want a section where we can can change the word if possible. Can anyone assist? P4m900-m7 se audio driver download. download special version. Fila Brazillia. Also, it needs to generate a password from LONDON01 to LONDON100. @echo off:Start2 cls goto Start:Start title Welcome to my Password Generator echo I will make you a new password. Echo Please write the password down somewhere in case you forget it. Echo --------------------------------------------------------------- echo 1) 1 Random Password echo 2) 5 Random Passwords echo 3) 10 Random Passwords echo Input your choice set input= set /p input= Choice: if%input%==1 goto A if NOT goto Start2 if%input%==2 goto B if NOT goto Start2 if%input%==3 goto C if NOT goto Start2:A cls echo Your password is%random% echo Now choose what you want to do. Echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if%input%==1 goto Start2 if NOT goto Start 2 if%input%==2 goto Exit if NOT goto Start 2:Exit exit:B cls echo Your 5 passwords are%random%,%random%,%random%,%random%,%random%. Echo Now choose what you want to do. Echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if%input%==1 goto Start2 if NOT goto Start 2 if%input%==2 goto Exit if NOT goto Start 2:C cls echo Your 10 Passwords are%random%,%random%,%random%,%random%,%random%,%random%,%random%,%random%,%random%,%random% echo Now choose what you want to do. Echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if%input%==1 goto Start2 if NOT goto Start 2 if%input%==2 goto Exit if NOT goto Start 2. If you want a fairly decent 'random', then I would suggest a fast program in C++ or something else (which can be distributed to your office systems). But, if you are stuck on cmd then: @echo off set minimum=0 set maximum=100 set pre=LONDON:A set randnumber=%random% if%randnumber% GEQ%minimum% ( if%randnumber% LEQ%maximum% ( echo%pre%%randnumber% goto END ) ) goto A:END Output Examples: Shouldn't be too hard to adjust that to work for your situation. Edit: As a supplement, I wanted to speak to this as many others have: This is an extremely insecure way to generate passwords and really shouldn't be used for anything outside of locking a phone, perhaps even not that. A true password generator should have 'salt' that is randomly generated for each password and is always unique. See More On Stackoverflow![]() ![]() Brute force on your password set (LONDON0 - LONDON100) would take seconds on a mid-line computer. Instead, you could use Python, something simple like: import string, random def genPass(prefix='LONDON', size=8, chars=string.ascii_uppercase + string.ascii_lowercase + string.digits + '@!&%$'): return prefix + '.join(random.choice(chars) for i in range(size)) print genPass() Which gets you a much more random, or at least unique, password set. If you want to change anything, just call genPass(prefix='NOTLONDON', size=2) instead, for example. This should fix your existing batch file so it works. @echo off set 'prefix=LONDON':Start2 cls goto Start:Start title Welcome to my Password Generator echo I will make you a new password. Echo Please write the password down somewhere in case you forget it. Echo --------------------------------------------------------------- echo 1) 1 Random Password echo 2) 5 Random Passwords echo 3) 10 Random Passwords echo Input your choice set input= set /p input= Choice: if '%input%.' Goto:Start if%input%==1 goto A if%input%==2 goto B if%input%==3 goto C goto:Start:A cls echo Your password is%prefix%%random%:reprompt1 echo Now choose what you want to do. Echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if '%input%.' Goto:reprompt1 if%input%==1 goto Start2 if%input%==2 goto Exit goto:reprompt1:Exit goto:EOF rem exit:B cls echo Your 5 passwords are%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%.:reprompt5 echo Now choose what you want to do. Echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if '%input%.' Goto:reprompt5 if%input%==1 goto Start2 if%input%==2 goto Exit goto:reprompt5:C cls echo Your 10 Passwords are%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%,%prefix%%random%:reprompt10 echo Now choose what you want to do. Echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if '%input%.' Goto:reprompt10 if%input%==1 goto Start2 if%input%==2 goto Exit goto:reprompt10 If you need something different, just let me know. Edit: I just noticed the comment indicating you need the results to be in the range of LONDON01 to LONDON100, so I modified the batch file to do that: @echo off set 'prefix=LONDON':Start2 cls goto Start:Start title Welcome to my Password Generator echo I will make you a new password.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |