批处理实现复杂密码(包含大小写字母数字符号)

声明:欢迎批评指正,修正了因为特殊字符,造成的缺少字符和长度问题

目标:生成12位密码,4位为一组分别放入大写字母,数字,小写字母和字符

运行方法:分别保存为“复杂密码.bat”和"zdb.txt",运行复杂密码.bat即可

运行环境:win7 32位

更新:更新了zdb.txt,特殊字符前面加^,比如zdb.txt中的^改成^^

复杂密码.bat(bat是后缀名)

@echo off
setlocal enabledelayedexpansion
set key=
for /L %%i in (1,1,12) do (
set /a dig=%%i%%4
if !dig! EQU 1 (
set /a n1=!random!%%25
set idx1=0
for /L %%a in (1,1,25) do (
if !n1! EQU !idx1! (
set /a num=%%a
)
set /a idx1+=1
)
)
if !dig! EQU 2 (
set /a n2=!random!%%10
set idx2=0
for /L %%b in (26,1,35) do (
if !n2! EQU !idx2! (
set /a num=%%b
)
set /a idx2+=1
)
)
if !dig! EQU 3 (
set /a n3=!random!%%24
set idx3=0
for /L %%c in (36,1,59) do (
if !n3! EQU !idx3! (
set /a num=%%c
)
set /a idx3+=1
)
)
if !dig! EQU 0 (
set /a n4=!random!%%8
set idx4=0
for /L %%d in (60,1,67) 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 is:!key!
pause
exit
 
 
zdb.txt
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
^~
^!
^@
^#
^$
^%
^^
^&
 

 

猜你喜欢

转载自blog.csdn.net/humors221/article/details/77127221