欢迎光临
我们一直在努力

怎样给文件加密最安全(一种方法)?-ASP教程,安全加密

建站超值云服务器,限时71元/月

这里提供了文件加密的一段小程序,以供大家参考.

<%@ language = vbscript%>

<%

response.expires = 0

p = "abcdefg"

set testpwd = new cpassword

testpwd.enpwd p

testpwd.unpwd testpwd.showpwd(true)

k = testpwd.showpwd(true)

l = testpwd.showpwd(false)

set testpwd = nothing

with response

.write "原文:" & p & "<br>"

.write "加密后:" & k & "<br>"

.write "解密后:" & l & "<br>"

end with

class cpassword

private cenpwd,cunpwd

private function my_hex(my_hex_source)

my_hex = hex(my_hex_source)

if len(my_hex) = 1 then

my_hex = "0" & my_hex

end if

end function

private function my_unhex(my_unhex_source)

if len(my_unhex_source) = 2 then

temp_value = my_hexreplace(left(my_unhex_source,1))

end if

my_unhex = temp_value * 16 + my_hexreplace(right(my_unhex_source,1))

end function

private function my_hexreplace(my_hexreplace_source)

if asc(my_hexreplace_source) > 64 then

my_hexreplace = asc(ucase(my_hexreplace_source)) – 55

else

my_hexreplace = asc(my_hexreplace_source) – 48

end if

end function

public property get showpwd(enp)

输出

if enp then

showpwd = cenpwd

else

showpwd = cunpwd

end if

end property

sub enpwd(enpwd_source)

if enpwd_source = "" then

cenpwd = 0

exit sub

else

randomize

key = rnd * 256

while key = 0

key = rnd * 256

wend

for i=1 to len(enpwd_source)

temp_string = key xor asc(mid(enpwd_source,i,1))

crc = crc + temp_string

cenpwd = cenpwd + my_hex(temp_string)

next

cenpwd = my_hex(key) + strreverse(cenpwd) + my_hex(crc mod 256)

end if

end sub

sub unpwd(unpwd_source)

if len(unpwd_source) < 6 or len(unpwd_source) mod 2 = 1 then

cunpwd = 0

exit sub

end if

old_key = my_unhex(left(unpwd_source,2))

old_crc = my_unhex(right(unpwd_source,2))

old_string = strreverse(mid(unpwd_source,3,len(unpwd_source)-4))

for i=1 to len(old_string) – 1 step 2

temp_value = my_unhex(mid(old_string,i,2))

crc_temp = crc_temp + temp_value

temp_string = temp_string + chr(temp_value xor old_key)

next

if old_crc <> (crc_temp mod 256) then

cunpwd = 403

exit sub

end if

cunpwd = temp_string

end sub

end class

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 怎样给文件加密最安全(一种方法)?-ASP教程,安全加密
分享到: 更多 (0)

相关推荐

  • 暂无文章