本文介绍了RC4加密和解密使用UTF-8的ASP经典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法,使在ASP页这项工作?
这是工作的罚款与字符集Windows的1253,但现在我不得不转换我的网站
为UTF-8和我唯一的问题是加密和解密。我已经加密的会员注册密码和现在使用UTF-8,解密后的密码是这样的: 286
请我NEAD一些帮助(对不起我的英文)。
这是RC4 code:
昏暗的S盒(255)
暗淡rc4Key(255) 子RC4Initialize(strPwd) 暗淡tempSwap,A,B intLength = LEN(strPwd) 要= 0至255 rc4Key(A)= ASC(MID(strpwd,(国防部intLength)+1,1)) S盒(一)=一
下一个 B = 0 要= 0至255
B =(B + S盒(一)+ rc4Key(一))模256
tempSwap = S盒(一)
S盒(一个)= S盒(B)的
S盒(B)= tempSwap
下一个 结束小组 功能EnDeCrypt(plaintxt,PSW) 昏暗的温度,A,I,J,K,cipherby,密码 I = 0
J = 0 RC4Initialize PSW 对于= 1到莱恩(plaintxt)
I =(I + 1)模256
J =(J + S盒(I))国防部256
TEMP = S盒(一)
S盒(I)= S盒(J)
S盒(J)=温度 K = S盒((S盒(我)+ S盒(J))模256) cipherby =升序(MID(plaintxt,一,1))XORķ
密码=密码&安培; CHR(cipherby)
下一个 enDeCrypt =密码 最终功能 功能RC4EnCryptASC(plaintxt,PSW) 昏暗的温度,A,I,J,K,cipherby,密码 I = 0
J = 0 RC4Initialize PSW 对于= 1到莱恩(plaintxt)
I =(I + 1)模256
J =(J + S盒(I))国防部256
TEMP = S盒(一)
S盒(I)= S盒(J)
S盒(J)=温度 K = S盒((S盒(我)+ S盒(J))模256) cipherby =升序(MID(plaintxt,一,1))XORķ
密码=密码&安培; |&放大器; cipherby
下一个 RC4EnCryptASC =密码 最终功能 功能RC4DeCryptASC(plaintxt,PSW) plaintxt = transformToCHR(plaintxt) 昏暗的温度,A,I,J,K,cipherby,密码 I = 0
J = 0 暗淡arrayEncrypted RC4Initialize PSW 对于= 1到莱恩(plaintxt)
I =(I + 1)模256
J =(J + S盒(I))国防部256
TEMP = S盒(一)
S盒(I)= S盒(J)
S盒(J)=温度 K = S盒((S盒(我)+ S盒(J))模256) cipherby =升序(MID(plaintxt,一,1))XORķ
密码=密码&安培; CHR(cipherby)
下一个 RC4DeCryptASC =密码 最终功能功能transformToCHR(plaintxt)
朦胧returnText,arrayEncrypted
arrayEncrypted =拆分(plaintxt,|) returnText = 为一个= 1到UBOUND(arrayEncrypted)
returnText = returnText&放大器; CHR(arrayEncrypted(a))的
下一个 transformToCHR = returnText
最终功能
解决方案
我认为你必须使用ASCW功能和等效等功能处理的Uni code字?
Is there a way to make this work in an ASP page?It was working fine with charset windows-1253 but now I have to convert my siteto UTF-8 and the only problem I have is encryption and decryption. I have encrypted members registration passwords and now with UTF-8, after decryption passwords looks like this: 2��8��6
Please I nead some help (sorry for my English).This is RC4 code:
Dim sbox(255)
Dim rc4Key(255)
Sub RC4Initialize(strPwd)
dim tempSwap, a, b
intLength = len(strPwd)
for a = 0 To 255
rc4Key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next
b = 0
for a = 0 To 255
b = (b + sbox(a) + rc4Key(a)) Mod 256
tempSwap = sbox(a)
sbox(a) = sbox(b)
sbox(b) = tempSwap
Next
End Sub
function EnDeCrypt(plaintxt, psw)
dim temp, a, i, j, k, cipherby, cipher
i = 0
j = 0
RC4Initialize psw
for a = 1 To Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i)= sbox(j)
sbox(j)= temp
k = sbox((sbox(i) + sbox(j)) Mod 256)
cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & Chr(cipherby)
next
enDeCrypt = cipher
end function
function RC4EnCryptASC(plaintxt, psw)
dim temp, a, i, j, k, cipherby, cipher
i = 0
j = 0
RC4Initialize psw
for a = 1 To Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i)= sbox(j)
sbox(j)= temp
k = sbox((sbox(i) + sbox(j)) Mod 256)
cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & "|"& cipherby
next
RC4EnCryptASC = cipher
end function
function RC4DeCryptASC(plaintxt, psw)
plaintxt = transformToCHR(plaintxt)
dim temp, a, i, j, k, cipherby, cipher
i = 0
j = 0
dim arrayEncrypted
RC4Initialize psw
for a = 1 To Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i)= sbox(j)
sbox(j)= temp
k = sbox((sbox(i) + sbox(j)) Mod 256)
cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & Chr(cipherby)
next
RC4DeCryptASC = cipher
end function
function transformToCHR(plaintxt)
dim returnText, arrayEncrypted
arrayEncrypted = split(plaintxt, "|")
returnText=""
for a = 1 to ubound(arrayEncrypted)
returnText=returnText&CHR(arrayEncrypted(a))
next
transformToCHR = returnText
end function
解决方案
i think you have to use AscW function and the equivalent other functions to deal with Unicode characters?
这篇关于RC4加密和解密使用UTF-8的ASP经典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!