回 帖 发 新 帖 刷新版面

主题:穷举法推算出输入的字符

穷举法推算出1~8位的字符  只是简单的应用下, 也可以是 9位,10位字符 等等...
只是写个思路, 如果要应要到实际的穷举法破解中,还是有一定难度的
有个问题  注释这个标号是怎么打出来的  '  ,我都是复制的 ...

编译好的  EXE下载
[url]http://upload.programfan.com/upfile/200703162037837.rar[/url]

下面是代码
cls
cs=0  '计算运算次数
start: input z$
if len(z$) >8 then print "Zhi Fu Guo Chang,  Qing Shu Ru 8 Wei Shu": goto start '如果字符超

过8位则反回  Input
if z$="" then print "Ni Shu Ru De Shi Kong Zi Fu": goto start '如果输入的是空字符,则返回

Input
time1$=time$  '把起使时间赋给time1$
for a1 = 97 to 122 '第一位数
for a2 = 97 to 122 '第二位数
for a3 = 97 to 122 '第三位数
for a4 = 97 to 122 '第四位数
for a5 = 97 to 122 '第五位数
for a6 = 97 to 122 '第六位数
for a7 = 97 to 122 '第七位数
for a8 = 97 to 122 '第八位数
a$ = chr$(a1) + chr$(a2) + chr$(a3) + chr$(a4) + chr$(a5) + chr$(a6) + chr$(a7) + chr$(a8) '

把a1 到 a8  转换成字母,并连接成字符串 , 8个字符
b$ = left$(a$,7)  ' 取a$ 从左边开始的7个字符
c$ = left$(a$,6)  ' 取a$ 从左边开始的6个字符
d$ = left$(a$,5)  ' 取a$ 从左边开始的5个字符
e$ = left$(a$,4)  ' 取a$ 从左边开始的4个字符
f$ = left$(a$,3)  ' 取a$ 从左边开始的3个字符
g$ = left$(a$,2)  ' 取a$ 从左边开始的2个字符
h$ = left$(a$,1)  ' 取a$ 从左边开始的1个字符
i$ = right$(a$,7) ' 取a$ 从右边开始的7个字符
j$ = right$(a$,6) ' 取a$ 从右边开始的6个字符
k$ = right$(a$,5) ' 取a$ 从右边开始的5个字符
l$ = right$(a$,4) ' 取a$ 从右边开始的4个字符
m$ = right$(a$,3) ' 取a$ 从右边开始的3个字符
n$ = right$(a$,2) ' 取a$ 从右边开始的2个字符
o$ = right$(a$,1) ' 取a$ 从右边开始的1个字符
locate 10,25 : print "Yun Shuan Zhong: ";a$  ' 在屏幕的第10行25列上显示  运算信息
cs = cs + 1  ' 累积运算次数
if h$=z$ then  ' 如果 h$ = z$ 那么先清屏,然后光标定位在第10行25列上打印  h$,以下IF语句都一样
cls 
locate 10,25 : print "Ni Shu Ru De Shi:  "; h$
goto theend

elseif o$=z$ then
cls 
locate 10,25 : print "Ni Shu Ru De Shi:  "; o$
goto theend

elseif g$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; g$
goto theend

elseif n$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; n$
goto theend

elseif f$=z$ then
cls 
locate 10,25 : print "Ni Shu Ru De Shi:  "; f$
goto theend

elseif m$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; m$
goto theend

elseif e$=z$ then
cls 
locate 10,25 : print "Ni Shu Ru De Shi:  "; e$
goto theend

elseif l$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; l$
goto theend

elseif d$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; d$
goto theend

elseif k$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; k$
goto theend

elseif c$=z$ then
cls 
locate 10,25 : print "Ni Shu Ru De Shi:  "; c$
goto theend

elseif j$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; j$
goto theend

elseif b$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; b$
goto theend

elseif i$=z$ then
cls
locate 10,25 : print "Ni Shu Ru De Shi:  "; i$
goto theend
end if
next a8,a7,a6,a5,a4,a3,a2,a1
theend:  ' GOTO的标号
time2$ = time$  ' 把结束的时间赋给  time2$
print 
locate 12,25: print "Qin Shi Shi Jian:  "; time1$  ' 显示起使运算时间
print
locate 14,25: print "Jie Shu Shi Jian:  "; time2$  ' 显示运算结束时间
print
locate 16,25: print "Yun Shuan Le `"; cs; "` Chi"  ' 显示运算了几次
locate 25,1 : print "Press any key to continue ..." ' 按任意键退出
do 
loop while inkey$=""

回复列表 (共2个回复)

沙发

1. 这是一种反其道而行之的方法,只能用来学习.
   而且要分清楚,实际使用中千万不要这样来解决问题
   目标字符串已知,别对南辕北辙.

2. 一大堆的 elseif 的半边表达式相同,完全可以使用 selct case 代替
   可以省略半边表达式的运算时间.

3. 同样的操作可以放入子程序,
   参数不同可以相应调用 SUB

板凳

说的是 ... 待我修改修改 ,  但是我还没有学到  SUB ...
  不明的是为什么不可以应用到实际中去?

我来回复

您尚未登录,请登录后再回复。点此登录或注册