asp字符串加密解密函数

2018-09-06 12:50

阅读:465

  <%
A_Key=split(96,44,63,80,,)定义密钥
*********加密的过程*********
FunctionEnCrypt(m)
DimstrChar,iKeyChar,iStringChar,I
k=0
forI=1toLen(m)
iKeyChar=Cint(A_Key(k))
iStringChar=Asc(mid(m,I,1))获取字符的ASCII码值
iCryptChar=iKeyCharXoriStringChar进行异或运算
对密钥进行移位运算
Ifk<3Then
k=k+1
Else
k=0
EndIf
c=c&Chr(iCryptChar)
next
EnCrypt=c
EndFunction
*********解密的过程*********
FunctionDeCrypt(c)
DimstrChar,iKeyChar,iStringChar,I
k=0
forI=1toLen(c)
iKeyChar=Cint(A_Key(k))
iStringChar=Asc(mid(c,I,1))
iDeCryptChar=iKeyCharXoriStringChar进行异或运算
对密钥进行移位运算
Ifk<3Then
k=k+1
Else
k=0
EndIf
strDecrypted=strDecrypted&Chr(iDeCryptChar)
next
DeCrypt=strDecrypted
EndFunction
%>


评论


亲,登录后才可以留言!