Encrypted download over the network forum, or other registration program users know that in the user registration, the system to the registered password for the MD5 encryption.
Describe how to use:
When you need to use MD5 encryption, call the Md5.asp file:
<!--#include file= "md5.asp"--> To encrypt characters:
MD5 (encrypted characters) md5.aspFile code:
<%
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 = Then
If Lvalue and 1 Then
LShift = &h80000000
Else
LShift = 0
End If
Exit Function
ElseIf ishiftbits < 0 Or ishiftbits > Then
Err.Raise 6
End If
If (Lvalue and M_l2power (31-ishiftbits)) Then
LShift = ((Lvalue and M_lonbits ()-(ishiftbits + 1)) * M_l2power (ishiftbits)) Or &h80000000
Else
LShift = ((Lvalue and M_lonbits (31-ishiftbits)) * M_l2power (ishiftbits))
End If
End Function
Private Function rshift (lvalue, Ishiftbits)
If ishiftbits = 0 Then
Rshift = Lvalue
Exit Function
ElseIf ishiftbits = Then
If Lvalue and &h80000000 Then
Rshift = 1
Else
Rshift = 0
End If
Exit Function
ElseIf ishiftbits < 0 Or ishiftbits > Then
Err.Raise 6
End If
Rshift = (lvalue and &h7ffffffe) \ M_l2power (ishiftbits)
If (Lvalue and &h80000000) Then
Rshift = (rshift Or (&h40000000 \ m_l2power (iShiftBits-1))
End If
End Function
Private Function rotateleft (lvalue, Ishiftbits)
Rotateleft = LShift (Lvalue, ishiftbits) Or Rshift (Lvalue, (32-ishiftbits))
End Function
Private Function addunsigned (LX, LY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim Lresult
LX8 = LX and &h80000000
LY8 = LY and &h80000000
LX4 = LX and &h40000000
LY4 = LY and &h40000000
LRESULT = (LX and &H3FFFFFFF) + (LY and &H3FFFFFFF)
If lX4 and LY4 Then
LRESULT = Lresult xor &h80000000 xor LX8 xor lY8
ElseIf lX4 Or lY4 Then
If Lresult and &h40000000 Then
LRESULT = Lresult xor &hc0000000 xor LX8 xor lY8
Else
LRESULT = Lresult xor &h40000000 xor LX8 xor lY8
End If
Else
LRESULT = Lresult XOR lX8 xor lY8
End If
addunsigned = Lresult
End Function
Private Function md5_f (x, Y, z)
Md5_f = (x and y) Or (not x) and Z)
End Function
Private Function md5_g (x, Y, z)
Md5_g = (x and z) Or (y and not z)
End Function
Private Function md5_h (x, Y, z)
Md5_h = (x xor y xor Z)
End Function
Private Function md5_i (x, Y, z)
Md5_i = (y Xor (x Or not z))
End Function
Private Sub md5_ff (A, B, C, D, X, S, AC)
A = addunsigned (A, addunsigned (addunsigned (Md5_f (b, C, D), x), AC)
A = Rotateleft (A, s)
A = Addunsigned (A, B)
End Sub
Private Sub Md5_gg (A, B, C, D, X, S, AC)
A = addunsigned (A, addunsigned (addunsigned (Md5_g (b, C, D), x), AC)
A = Rotateleft (A, s)
A = Addunsigned (A, B)
End Sub
Private Sub md5_hh (A, B, C, D, X, S, AC)
A = addunsigned (A, addunsigned (addunsigned (Md5_h (b, C, D), x), AC)
A = Rotateleft (A, s)
A = Addunsigned (A, B)
End Sub
Private Sub Md5_ii (A, B, C, D, X, S, AC)
A = addunsigned (A, addunsigned (addunsigned (md5_i (b, C, D), x), AC)
A = Rotateleft (A, s)
A = Addunsigned (A, B)
End Sub
Private Function Converttowordarray (smessage)
Dim Lmessagelength
Dim Lnumberofwords
Dim Lwordarray ()
Dim lbyteposition
Dim Lbytecount
Dim Lwordcount
Private Function Wordtohex (lvalue)
Dim Lbyte
Dim Lcount
For lcount = 0 to 3
Lbyte = Rshift (lvalue, Lcount * bits_to_a_byte) and m_lonbits (bits_to_a_byte-1)
Wordtohex = Wordtohex & Right ("0" & Hex (Lbyte), 2)
Next
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.