[原创]计算密码强度(按每秒1千万次试码速度计算)
点击浏览该文件
$freeform
! 计算密码强度(按每秒1千万次试码速度计算)
! shizhengwei@yahoo.com.cn
use msflib
integer s(5),n
real*8 t,d
parameter (k=125,y=1d7*365*24*3600)
character a
character*4 h
character*(k) code
s=0
write(*,'(2a)') char(13),'计算密码强度(按每秒1千万次试码速度计算)'
write(*,'(2a,\)') char(13),'请输入要测试的密码:'
read(*,'(a)') code
n=len_trim(code)
do i=1,n ! 分析字符范围
a=code(i:i)
if(a.ge.'0'.and.a.le.'9') then ! 包含数字
s(1)=10
else if(a.ge.'a'.and.a.le.'z') then ! 包含小写字母
s(2)=26
else if(a.ge.'A'.and.a.le.'Z') then ! 包含大写字母
s(3)=26
else if(a.ge.char(161).and.a.le.char(254)) then ! 包含汉字
s(4)=94
else ! 包含空格和其它字符
s(5)=33
end if
end do
t=0d0
do i=1,5 ! 累加字符种数
t=t+s(i)
end do
t=t**n/y ! 计算强度并输出
write(*,'(2a,\)') char(13),'密码破解强度:'
if(t.lt.1) then
t=t*365
if(t.lt.1) then
call t2h(t*24,h)
if(h.eq.'0') then
write(*,'(2a)') '不足1小时'
else
write(*,'(2a)') trim(h),'小时'
end if
else
call t2h(t,h)
write(*,'(2a)') trim(h),'天'
end if
else if(t.ge.1.and.t.lt.1d4) then
call t2h(t,h)
write(*,'(2a)') trim(h),'年'
else if(t.ge.1d4.and.t.lt.1d6) then
call t2h(t/1d4,h)
write(*,'(2a)') trim(h),'万年'
else if(t.ge.1d6) then
write(*,'(a)') '不少于100万年'
end if
write(*,'(/,2a)') char(13),'按任意键结束程序'
a=getcharqq()
end
subroutine t2h(t,h) ! 数字转换为字符
real*8 t
character*4 h
write(h,'(i4)') int(t)
n=verify(h,' ')
if(n.gt.1) h=h(n:4)
end
$freeform
! 计算密码强度(按每秒1千万次试码速度计算)
! shizhengwei@yahoo.com.cn
use msflib
integer s(5),n
real*8 t,d
parameter (k=125,y=1d7*365*24*3600)
character a
character*4 h
character*(k) code
s=0
write(*,'(2a)') char(13),'计算密码强度(按每秒1千万次试码速度计算)'
write(*,'(2a,\)') char(13),'请输入要测试的密码:'
read(*,'(a)') code
n=len_trim(code)
do i=1,n ! 分析字符范围
a=code(i:i)
if(a.ge.'0'.and.a.le.'9') then ! 包含数字
s(1)=10
else if(a.ge.'a'.and.a.le.'z') then ! 包含小写字母
s(2)=26
else if(a.ge.'A'.and.a.le.'Z') then ! 包含大写字母
s(3)=26
else if(a.ge.char(161).and.a.le.char(254)) then ! 包含汉字
s(4)=94
else ! 包含空格和其它字符
s(5)=33
end if
end do
t=0d0
do i=1,5 ! 累加字符种数
t=t+s(i)
end do
t=t**n/y ! 计算强度并输出
write(*,'(2a,\)') char(13),'密码破解强度:'
if(t.lt.1) then
t=t*365
if(t.lt.1) then
call t2h(t*24,h)
if(h.eq.'0') then
write(*,'(2a)') '不足1小时'
else
write(*,'(2a)') trim(h),'小时'
end if
else
call t2h(t,h)
write(*,'(2a)') trim(h),'天'
end if
else if(t.ge.1.and.t.lt.1d4) then
call t2h(t,h)
write(*,'(2a)') trim(h),'年'
else if(t.ge.1d4.and.t.lt.1d6) then
call t2h(t/1d4,h)
write(*,'(2a)') trim(h),'万年'
else if(t.ge.1d6) then
write(*,'(a)') '不少于100万年'
end if
write(*,'(/,2a)') char(13),'按任意键结束程序'
a=getcharqq()
end
subroutine t2h(t,h) ! 数字转换为字符
real*8 t
character*4 h
write(h,'(i4)') int(t)
n=verify(h,' ')
if(n.gt.1) h=h(n:4)
end
[此贴子已经被作者于2012-8-9 9:00:08编辑过]