我试图从youtube运行密码生成器。 这是代码:
@echo off
chcp 1257
setlocal EnableDelayedExpansion
set alpha=
aąbcčdeęėfghiįjklmnopqrsštuųūvwxyzžAĄBCČDEĘĖFGHIĮJKLMNOPQRSŠTUŲŪVWXYZŽ
For /L %%j in (1,1,13) DO CALL:GEN
echo Your Random Password is [ %PASSWORD% ]
EndLocal
pause
:GEN
For /L %%j in (1,1,10) DO (
if %random% gtr 10000 ( set PASSWORD=%PASSWORD%%random:~0,1% ) else (
set /a i=%random:~1,1%+%random:~1,1%
if !i! gtr 25 set i=25
set PASSWORD=%PASSWORD%!alpha:~%i%,1! )
)
这会返回1个随机密码。我需要10个密码,所以我尝试在此行之前创建for循环:对于/ L %% j in(1,1,13)DO CALL:GEN。然后它返回10行文本,但没有密码:
Active code page: 1257
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Your Random Password is [ ]
Press any key to continue . . .
我该如何解决这个问题?
答案 0 :(得分:1)
@echo off & setlocal EnableDelayedExpansion
chcp 1257
set "alpha=aabccdeeefghiijklmnopqrsštuuuvwxyzžAABCCDEEEFGHIIJKLMNOPQRSŠTUUUVWXYZŽ"
set alphaCnt=70
For /L %%j in (1,1,10) DO CALL :GEN %%j
pause
Goto :Eof
:GEN
Set "Password="
For /L %%j in (1,1,10) DO (
Set /a i=!random! %% alphaCnt
Call Set PASSWORD=!PASSWORD!%%alpha:~!i!,1%%
)
echo Your Random Password %1 is [%PASSWORD%]
示例输出:
Your Random Password 1 is [EÜllxleUOc]
Your Random Password 2 is [RBGEoÄulEF]
Your Random Password 3 is [AfuuAEFwMe]
Your Random Password 4 is [kuaEjuLicr]
Your Random Password 5 is [ModgGsANÄE]
Your Random Password 6 is [MzEqSWJWCB]
Your Random Password 7 is [oÜcrFUqGpj]
Your Random Password 8 is [kRHDCqiciÜ]
Your Random Password 9 is [gUYjjSiicQ]
Your Random Password 10 is [cuuAOÜixVY]
答案 1 :(得分:0)
试试这个。您可以在alp
变量中添加/删除字符。
@echo off
setlocal enabledelayedexpansion
set "alp=a A b B c C d D E e f F g G h H I I j J k K l L m M n N p P q Q r R s S t T u U v V w W x X y Y z Z 0 1 2 3 4 5 6 7 8 9"
set "cnt=0"
for %%a in (%alp%) do (
set "rn.!cnt!=%%a"
set /a "cnt+=1"
)
for /l %%i in (1,1,10) do (
set "pssw="
for /l %%a in (1,1,13) do (
set /a "rand=!random! %% cnt"
for %%b in (!rand!) do set "pssw=!pssw!!rn.%%b!"
)
echo Your random password is: [ !pssw! ]
)