升級MD5.ASP,打造完全動態不重複的安全加密代碼

來源:互聯網
上載者:User
安全|動態|加密|重複

做一個完全動態密碼,讓相同的密碼產生不同的結果
密碼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




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.