如何解密vb加密过的字符串,有加密代码

来源:百度知道 编辑:UC知道 时间:2024/05/22 02:53:10
<% function encrypt(ecode)
Dim texts
dim i
for i=1 to len(ecode)
texts=texts & chr(asc(mid(ecode,i,1))+i)
next
encrypt = texts
end function
function decrypt(dcode)
dim texts
dim i
for i=1 to len(dcode)
texts=texts & chr(asc(mid(dcode,i,1))-i)
next
decrypt=texts
end function
function mistake(preString)
Dim texts
Dim seed
Dim i,length
prestring = trim(preString)
length = len(preString)
seed = length
Randomize(length)
texts = ""
for i = 1 to length
seed = int(94*rnd(-asc(mid(preString,i,1))-seed*asc(right(prestring,1)))+32)
texts = texts & chr(seed) & chr(int(94*rnd(-seed)+32))
next
dim dist
dist=""
for i = 1 to len(texts)
if mid(texts,i,1)<>"'" then

上述代码已经含有加密和解密的函数:
一、加密函数是:encrypt
调用举例:msgbox encrypt("123456")
返回值是:"2468:<"
二、解密函数是:decrypt
调用举例:msgbox decrypt("2468:<")
返回值是:"123456"

'不是有解密函数了吗?
'调用函数就行,如下
原始字串$ = "Test"
加密串$ = encrypt(原始字串$)
原始字串$ = decrypt(加密串$)
-----------------------------
Function decrypt(dcode)
Dim texts
Dim i
For i = 1 To Len(dcode)
texts = texts & Chr(Asc(Mid(dcode, i, 1)) - i)
Next
decrypt = texts
End Function

加密(encrypt)是将字符串中的字符与该字符对应的序号相加,相加的数对应的ascii码替换原字符。
解密(decrypt)就是反过来