教你做一個(gè)完全動(dòng)態(tài)的密碼
作者: 來源: 發(fā)布時(shí)間:2011-6-3 9:19:52 點(diǎn)擊:
這篇文章跟大家一起分享的是教你升級MD5.ASP,打造完全動(dòng)態(tài)不重復(fù)的加密代碼,希望對大家有所幫助。
做一個(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")'=======================================
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
密碼aaa經(jīng)過第一次運(yùn)算后結(jié)果為:
jlce1d65ec3b91556234879c9db8f6da1123
第二次:
hjmnbe0d01cc1fbd3e18ae7431fa52fb3ce4
第三次:
grttb05901915e121d83ebefad7e809ef1b0
... ...
當(dāng)然,亦可還原比較
以下我根據(jù)動(dòng)網(wǎng)MD5函數(shù)修改后的代碼,
'=======================================
'word 要加密的字符串
'返回加密后的 word
'例:response.write Md6("aaa")'=======================================
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
[收藏此文章]