asp字符串加密解密函数
程序员文章站
2023-12-30 17:01:10
<% a_key=split("96,44,63,80",",") '定义密钥 '*********加密的过程*********&n...
<%
a_key=split("96,44,63,80",",") '定义密钥
'*********加密的过程*********
function encrypt(m)
dim strchar,ikeychar,istringchar,i
k=0
for i = 1 to len(m)
ikeychar =cint(a_key(k))
istringchar = asc(mid(m,i,1)) '获取字符的ascii码值
icryptchar = ikeychar xor istringchar '进行异或运算
'对密钥进行移位运算
if k<3 then
k=k+1
else
k=0
end if
c = c & chr(icryptchar)
next
encrypt = c
end function
'*********解密的过程*********
function decrypt(c)
dim strchar, ikeychar, istringchar, i
k=0
for i = 1 to len(c)
ikeychar =cint(a_key(k))
istringchar = asc(mid(c,i,1))
idecryptchar = ikeychar xor istringchar '进行异或运算
'对密钥进行移位运算
if k<3 then
k=k+1
else
k=0
end if
strdecrypted = strdecrypted & chr(idecryptchar)
next
decrypt = strdecrypted
end function
%>
a_key=split("96,44,63,80",",") '定义密钥
'*********加密的过程*********
function encrypt(m)
dim strchar,ikeychar,istringchar,i
k=0
for i = 1 to len(m)
ikeychar =cint(a_key(k))
istringchar = asc(mid(m,i,1)) '获取字符的ascii码值
icryptchar = ikeychar xor istringchar '进行异或运算
'对密钥进行移位运算
if k<3 then
k=k+1
else
k=0
end if
c = c & chr(icryptchar)
next
encrypt = c
end function
'*********解密的过程*********
function decrypt(c)
dim strchar, ikeychar, istringchar, i
k=0
for i = 1 to len(c)
ikeychar =cint(a_key(k))
istringchar = asc(mid(c,i,1))
idecryptchar = ikeychar xor istringchar '进行异或运算
'对密钥进行移位运算
if k<3 then
k=k+1
else
k=0
end if
strdecrypted = strdecrypted & chr(idecryptchar)
next
decrypt = strdecrypted
end function
%>