Batch processing of complex passwords (out-of-order uppercase and lowercase alphanumeric symbols)

Test environment: windows10

Disclaimer: Missing characters and length errors due to special characters have been corrected

Instructions:

1. The first code:

For a text editor such as editplus, save, select "all files" as the save type and name "password.bat"

You can modify the password length, the number of uppercase and lowercase alphanumeric symbols, corresponding to the number of uppercase and lowercase alphanumeric symbols in the TXT file of the second code segment

2. The second code:

Text editor such as editplus, save, select "all files" as the save type, and the name is "zdb.txt", the content can be modified as needed

3. Put the first and second code in the same directory

4. The original key is generated according to a group of uppercase letters, numbers, lowercase letters, and symbols. The out-of-order key is the out-of-order arrangement of the original password.

The final password is an out-of-order password, which can be used for out-of-order or complex out-of-order key generation

5. The code involves the syntax of variable nesting and delay, which can be used as a reference for related applications

6. If the original key is written with a fixed value, you can write the following call set "key=XXXXXX", and keep the variable len and the fixed value length, pay attention to the special characters in the fixed value to be escaped, add ^

7. Fix an error

Password.bat code:

@echo off
setlocal enabledelayedexpansion
rem 密钥长度
set len=32
rem 大写字母数量
set caplen=25
rem 数字数量
set numlen=10
rem 小写字母数量
set noncaplen=24
rem 符号数量
set signlen=8
set key=
for /L %%i in (1,1,!len!) do (
set /a dig=%%i%%4
if !dig! EQU 1 (
set /a n1=!random!%%!caplen!
set idx1=0
for /L %%a in (1,1,!caplen!) do (
if !n1! EQU !idx1! (
set /a num=%%a
)
set /a idx1+=1
)
)
if !dig! EQU 2 (
set /a n2=!random!%%!numlen!
set idx2=0
set /a minnum=!caplen!+1
set /a maxnum=!minnum!+!numlen!-1
for /L %%b in (!minnum!,1,!maxnum!) do (
if !n2! EQU !idx2! (
set /a num=%%b
)
set /a idx2+=1
)
)
if !dig! EQU 3 (
set /a n3=!random!%%!noncaplen!
set idx3=0
set /a minnoncap=!maxnum!+1
set /a maxnoncap=!minnoncap!+!noncaplen!-1
for /L %%c in (!minnoncap!,1,!maxnoncap!) do (
if !n3! EQU !idx3! (
set /a num=%%c
)
set /a idx3+=1
)
)
if !dig! EQU 0 (
set /a n4=!random!%%!signlen!
set idx4=0
set /a minsign=!maxnoncap!+1
set /a maxsign=!minsign!+!signlen!-1
for /L %%d in (!minsign!,1,!maxsign!) do (
if !n4! EQU !idx4! (
set /a num=%%d
)
set /a idx4+=1
)
)
set idx=1
for /F %%j in (zdb.txt) do (
if !num! EQU !idx! (
set key=!key!%%j
)
set /a idx+=1
)
)
echo 原始密钥是!key!
echo.
set key1=
for /L %%z in (!len!,-1,1) do (
rem 取随机索引
set /a idx=%random%%%%%z
rem 下一个索引
set /a idx1=!idx!+1
call call set "o=%%%%key:~%%idx%%,1%%%%"
if !idx! equ 0 (
call call set "key=%%%%key:~%%idx1%%%%%%"
) else (
set /a maxidx=%%z-1
if !idx! geq !maxidx! (
set idx=!maxidx!
call call set "key=%%%%key:~0,%%idx%%%%%%"
) else (
call call set "key=%%%%key:~0,%%idx%%%%%%%%%%key:~%%idx1%%%%%%"
)
)
set key1=!key1!!o!
)
echo 乱序密钥是!key1!
echo.
echo 最终密钥是!key1!
echo.
pause
exit

zdb.txt code:

A
B
C
D
E
F
G
H
I
J
K
L
M
N
P
Q
R
S
T
U
V
W
X
Y
Z
0
1
2
3
4
5
6
7
8
9
a
b
c
d
e
f
g
h
i
j
k
m
n
p
q
r
s
t
u
v
w
x
y
z
^~
^!
^@
^#
^$
^%
^^
^&

(End of full text)

 

Guess you like

Origin blog.csdn.net/humors221/article/details/107582158