最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用ASP加密算法加密你的数据(二)
时间:2022-06-30 09:19:06 编辑:袖梨 来源:一聚教程网
下面的代码就是能够同时实现这个功能的函数
Crypt.asp文件
<%
Dim g_Key
Const g_CryptThis = "Now is the time for
all good men to come to the aid of their country."
Const g_KeyLocation = "c:key.txt"
g_Key = mid(ReadKeyFromFile(g_KeyLocation),1,Len(g_CryptThis))
Response.Write "
ORIGINAL STRING: " & g_CryptThis & "
"
Response.Write "
KEY VALUE: " & g_Key & "
"
Response.Write "
ENCRYPTED CYPHERTEXT: " & EnCrypt(g_CryptThis) & "
"
Response.Write "
DECRYPTED CYPHERTEXT: " & DeCrypt(EnCrypt(g_CryptThis)) & "
"
Function EnCrypt(strCryptThis)
Dim strChar, iKeyChar, iStringChar, I
for I = 1 to Len(strCryptThis)
iKeyChar = Asc(mid(g_Key,I,1))
iStringChar = Asc(mid(strCryptThis,I,1))
' *** uncomment below to encrypt with addition,
' iCryptChar = iStringChar + iKeyChar
iCryptChar = iKeyChar Xor iStringChar
strEncrypted = strEncrypted & Chr(iCryptChar)
next
EnCrypt = strEncrypted
End Function
Function DeCrypt(strEncrypted)
Dim strChar, iKeyChar, iStringChar, I
for I = 1 to Len(strEncrypted)
iKeyChar = (Asc(mid(g_Key,I,1)))
iStringChar = Asc(mid(strEncrypted,I,1))
' *** uncomment below to decrypt with subtraction
' iDeCryptChar = iStringChar - iKeyChar
iDeCryptChar = iKeyChar Xor iStringChar
strDecrypted = strDecrypted & Chr(iDeCryptChar)
next
DeCrypt = strDecrypted
End Function
Function ReadKeyFromFile(strFileName)
Dim keyFile, fso, f
set fso = Server.CreateObject("Scripting.FileSystemObject")
set f = fso.GetFile(strFileName)
set ts = f.OpenAsTextStream(1, -2)
相关文章
- 无期迷途主线前瞻直播总结 无期迷途主线前瞻直播内容介绍 11-22
- 以下哪种非遗技艺是用针在纸上绣画 蚂蚁新村11月21日答案 11-22
- 江南百景图听风塔怎么样 11-22
- 原神恰斯卡圣遗物怎么搭配 11-22
- 2024年霸王茶姬11月22日口令是什么 2024.11.22霸王茶姬口令介绍 11-22
- 光遇11.21季节蜡烛在哪里 光遇11月21日季节蜡烛位置攻略 11-22