安全|動態|加密|重複
做一個完全動態密碼,讓相同的密碼產生不同的結果
密碼aaa經過第一次運算後結果為:
jlce1d65ec3b91556234879c9db8f6da1123
第二次:
hjmnbe0d01cc1fbd3e18ae7431fa52fb3ce4
第三次:
grttb05901915e121d83ebefad7e809ef1b0
... ...
當然,亦可還原比較
以下我根據動網MD5函數修改後的代碼,
'=======================================
'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 需要驗證的字串,OldWord 加密後的原字串
'返回比較後的結果,如果相等返回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