动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   VBScript → 阅读文章

 纯使用VBScript来实现加密

作者来源: 
阅读 1822 人次 , 2006-4-3 



<%
'### to encrypt/decrypt include this code in your page
'### strmyencryptedstring = encryptstring(strstring)
'### strmydecryptedstring = decryptstring(strmyencryptedstring)
'### you are free to use this code as long as credits remain in place
'### also if you improve this code let me know.

private function encryptstring(strstring)
'####################################################################
'### crypt function (c) 2001 by slavic kozyuk grindkore@yahoo.com ###
'### arguments: strstring <--- string you wish to encrypt ###
'### output: encrypted hex string ###
'####################################################################

dim charhexset, intstringlen, strtemp, strraw, i, intkey, intoffset
randomize timer

intkey = round((rnd * 1000000) + 1000000) '##### key bitsize
intoffset = round((rnd * 1000000) + 1000000) '##### keyoffset bitsize

if isnull(strstring) = false then
strraw = strstring
intstringlen = len(strraw)

for i = 0 to intstringlen - 1
strtemp = left(strraw, 1)
strraw = right(strraw, len(strraw) - 1)
charhexset = charhexset & hex(asc(strtemp) * intkey)
& hex(intkey)
next

encryptstring = charhexset & "|" & hex(intoffset + intkey) & "|" & hex(intoffset)
else
encryptstring = ""
end if
end function

 

private function decryptstring(strcryptstring)
'####################################################################
'### crypt function (c) 2001 by slavic kozyuk grindkore@yahoo.com ###
'### arguments: encrypted hex stringt ###
'### output: decrypted ascii string ###
'####################################################################
'### note this function uses hexconv() and get_hxno() functions ###
'### so make sure they are not removed
###
'####################################################################

dim strraw, arhexcharset, i, intkey, intoffset, strrawkey, strhexcrypdata

strrawkey = right(strcryptstring, len(strcryptstring) - instr(strcryptstring, "|"))
intoffset = right(strrawkey, len(strrawkey) - instr(strrawkey,"|"))
intkey = hexconv(left(strrawkey, instr(strrawkey, "|") - 1)) - hexconv(intoffset)
strhexcrypdata = left(strcryptstring, len(strcryptstring) - (len(strrawkey) + 1))

arhexcharset = split(strhexcrypdata, hex(intkey))

for i=0 to ubound(arhexcharset)
strraw = strraw & chr(hexconv(arhexcharset(i))/intkey)
next

decryptstring = strraw
end function

 

private function hexconv(hexvar)
dim hxx, hxx_var, multiply
if hexvar <> "" then
hexvar = ucase(hexvar)
hexvar = strreverse(hexvar)
dim hx()
redim hx(len(hexvar))
hxx = 0
hxx_var = 0
for hxx = 1 to len(hexvar)
if multiply = "" then multiply = 1
hx(hxx) = mid(hexvar,hxx,1)
hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
multiply = (multiply * 16)
next
hexvar = hxx_var
hexconv = hexvar
end if
end function

private function get_hxno(ghx)
if ghx = "a" then
ghx = 10
elseif ghx = "b" then
ghx = 11
elseif ghx = "c" then
ghx = 12
elseif ghx = "d" then
ghx = 13
elseif ghx = "e" then
ghx = 14
elseif ghx = "f" then
ghx = 15
end if
get_hxno = ghx
end function

%>

 本文Tagsmd5  加密  组网  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:vbscript错误代码及对应解释大全
· 下一篇:在ASP页里面注册DLL的VBScript CLASS
· VBScript 运行时错误
· VBScript Timer 函数
· VBScript Month 函数
· VBScript Left 函数
· VBScript VarType 函数


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077