ASP,如何转换密码

来源:百度知道 编辑:UC知道 时间:2024/04/20 22:08:13
在ASP,如何把注册用户的密码转成其它字符,验证时又如何转回来?
如果把数字转成其它字符,转回来时还是数字类型的吗?如果不是该怎样做?

用MD5加密的方式。
把用户的密码通过MD5加密后存储在数据库里,验证的时候只要把用户输入的密码用MD5加密以后与数据库里面的比较,一样就是正确的密码。

MD5源代码:
md5.asp
-------------------
<%
Private Const BITS_TO_A_BYTE = 8
Private Const BYTES_TO_A_WORD = 4
Private Const BITS_TO_A_WORD = 32

Private m_lOnBits(30)
Private m_l2Power(30)

Private Function LShift(lValue, iShiftBits)
If iShiftBits = 0 Then
LShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And 1 Then
LShift = &H80000000
Else
LShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
Err.Raise 6
End If

If (lValue And m_l2Power(31 - iShiftBits)) Then
LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000
Else
LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits))
End If
End Function

P