asp字符串加密解密函數
更新時間:2007年06月30日 00:00:00 作者:
<%
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
%>
相關文章
Webform 內置對象 Session對象、Application全局對象,ViewState詳細介紹
這篇文章主要介紹了Webform 內置對象 Session對象、Application全局對象,ViewState的相關資料,需要的朋友可以參考下2016-09-09