我做一个会员的帐号功能:当中有这个会员的帐号,密码,金钱等等,我全给他们用md5加上密后,能再还原显示吗??
或者谁搞个最最简单的加密给我看看,再写上用法,呵呵,先谢过
你可用能解密的加密方法来加密的,不过不明白你的金钱是什么形式的要加密,
如RC4加密,或RSA加密。下面是RC4例,你看能否用得上。
可写成一个函数,然后像MD5一样用
[QUOTE]
<HEAD>
<META HTTP-EQUIV="Content-Language" CONTENT="zh-cn">
</HEAD>
<%
key="sdfjal;dfjaoiejojfafnsanf;aufweijoanfanfaieufowejrwnf;aupagyuweranfsajfagfuoag" '私钥
Sub RC4Initialize(strPwd,ByRef sbox,ByRef key)
dim tempSwap
dim a
dim b
intLength = len(strPwd)
For a = 0 To 255
key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next
b = 0
For a = 0 To 255
b = (b + sbox(a) + key(a)) Mod 256
tempSwap = sbox(a)
sbox(a) = sbox(b)
sbox(b) = tempSwap
Next
End Sub
Function EnCrypt(plaintxt, psw)
Dim sbox(255)
Dim key(255)
dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher
i = 0
j = 0
RC4Initialize psw,sbox,key
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)) Mod 256)
cipherby = asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & "&#"&cipherby&";" 'eg: €
Next
EnCrypt = cipher
End Function
Function DeCrypt(cryptxt, psw)
Dim sbox(255)
Dim key(255)
dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher
i = 0
j = 0
RC4Initialize psw,sbox,key
crypchar=split(cryptxt,";",-1,1)
crypttxtlen=Ubound(crypchar)
For a = 1 To crypttxtlen
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)) Mod 256)
tmpcryptxt=mid(crypchar(i-1),3)
cipherby = tmpcryptxt Xor k
cipher = cipher & "&#"&cipherby&";" 'eg: €
Next
DeCrypt = cipher
End Function
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
plaintext=request.form("plaintext")
response.write "<br>输入的明文字符串是:"&plaintext
cryptext=EnCrypt(plaintext,key)
response.write "<br>加密后的密文字符串:" &cryptext
decryptext=DeCrypt(cryptext,key)
response.write "<br>解密输出的字符串是:" &decryptext
end if
%>
<title>RC4加密算法模拟</title>
<FORM METHOD="POST" ACTION="index.asp">
<P>请输入需要加密的明文:<INPUT TYPE="text" NAME="plaintext" SIZE="20">
</P>
<P>
<INPUT TYPE="submit" VALUE="进行加密" NAME="B1">
<INPUT TYPE="reset" VALUE="重新输入" NAME="B2"></P>
</FORM>