编程语言

img bigbird998

升级MD5.ASP,打造完全动态不重复的安全加密代码

发表于2004/10/15 23:21:00  1783人阅读

分类: 加密与解密技术

'做一个完全动态的密码,让相同的密码生成不同的结果
'密码aaa经过第一次运算后结果为:
'jlce1d65ec3b91556234879c9db8f6da1123
'第二次:
'hjmnbe0d01cc1fbd3e18ae7431fa52fb3ce4
'第三次:
'grttb05901915e121d83ebefad7e809ef1b0
'... ...
'当然,亦可还原比较
'以下我根据动网MD5函数修改后的代码,
'=======================================
'= word 要加密的字符串
'= 返回加密后的 word
'=例:response.write Md6("aaa")
'=======================================

Function Md6(Word)
Dim Random, RandomNum, reRandom, reWord
Randomize
Do While Len(Random) < 4                                                           '产生一个4位随即小写字母 
RandomNum = Chr(25 * rnd + 97 )
Random = Random & RandomNum
Loop                                                              
reRandom = Md5(Random)                                                          'MD5(4位随即字母)
reWord = Md5(Word)                                                                  'MD5(加密字符)
Md6 = LCase(Random & Md5(reRandom + reWord))                 'MD6=小写(4位随即小写字母&MD5(4位随即字母+MD5(加密字符))
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

阅读全文
0 0

相关文章推荐

img
取 消
img