|
Answer» i made this code to generate random passwords. the password often has spaces in it can some one help me fix it.
Code: [Select]echo off :7 cls set /p t=password length: set /a t=%t%-1 set /a p=%random% %%9 for /l set /a c=%random% %%18 set d=%c% if %c%==10 set d=a if %c%==11 set d=b if %c%==12 set d=c if %c%==13 set d=d if %c%==14 set d=e if %c%==15 set d=f if %c%==16 set d=g if %c%==17 set d=h if %c%==18 set d=i set p=%p%%d% set /a l=%l%+1 goto a :out echo %p% PAUSE > nul goto 7 I tried to fix it, but I simply could not GUESS how the for statement was constructed. I checked in with the snippet closet and turned up this masterpiece that only needed a few tweaks.
Code: [Select]echo off setlocal set pool=ABCDEFGHIJKLMNOPQRSTUVWXYZabcde[email protected]$?
:retry set /p len=Enter length of KEY: if %len% GTR 65 goto retry
for /l %%i in (1, 1, %len%) do call :GetNext echo Key: %key% goto :eof
:GetNext set /a rnd=(%random% %% 65) - 1 call set NEW=%%pool:~%rnd%,1%% set key=%key%%new% goto :eof
Good luck.
|