明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

升級MD5.ASP,打造完全動(dòng)態(tài)不重復(fù)的安全加密代碼

[摘要]做一個(gè)完全動(dòng)態(tài)的密碼,讓相同的密碼生成不同的結(jié)果密碼aaa經(jīng)過第一次運(yùn)算后結(jié)果為:jlce1d65ec3b91556234879c9db8f6da1123第二次:hjmnbe0d01cc1fbd3e18ae7431fa52fb3ce4第三次:grttb05901915e121d83ebefad7e...

做一個(gè)完全動(dòng)態(tài)的密碼,讓相同的密碼生成不同的結(jié)果
密碼aaa經(jīng)過第一次運(yùn)算后結(jié)果為:
jlce1d65ec3b91556234879c9db8f6da1123
第二次:
hjmnbe0d01cc1fbd3e18ae7431fa52fb3ce4
第三次:
grttb05901915e121d83ebefad7e809ef1b0
... ...
當(dāng)然,亦可還原比較
以下我根據(jù)動(dòng)網(wǎng)MD5函數(shù)修改后的代碼,
'=======================================
'word 要加密的字符串
'返回加密后的 word
'例:response.write Md6("aaa")
'www.knowsky.com
'=======================================

Function Md6(Word)
Dim Random, RandomNum, reRandom, reWord
Randomize
Do While Len(Random) < 4
RandomNum = Chr(25 * rnd + 97 )
Random = Random & RandomNum
Loop                                                              
reRandom = Md5(Random)                         
reWord = Md5(Word)                                
Md6 = LCase(Random & Md5(reRandom + reWord))
End Function

'=======================================
'Wrod 需要驗(yàn)證的字符串,OldWord 加密后的原字符串
'返回比較后的結(jié)果,如果相等返回True,反之False
'例:pwd=“aaa“
'        old_pwd=“grttb05901915e121d83ebefad7e809ef1b0“
'        if Md6Back(pwd,old_pwd)=TRUE then
'        ... ...
'=======================================

Function Md6Back(Word, OldWord)
Dim Random, RandomNum, reRandom, reWord
Random = Mid(OldWord, 1, 4)                        
reRandom = Md5(Random)                          
reWord = Md5(Word)                    
If OldWord = Random & Md5(reRandom + reWord) Then
      Md6Back = True
  Else
      Md6Back = False
End If
End Function