This is a foreign reprinatic function, and any character can be converted to MD5 16 as a character encryption, and is irreversible.
<%
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 ThenLShift = lValueExit FunctionElseIf iShiftBits = 31 ThenIf lValue And 1 ThenLShift = & H80000000ElseLShift = 0End IfExit FunctionElseIf iShiftBits <0 Or iShiftBits> 31 ThenErr.Raise 6End If
If (lValue And m_l2Power (31 - iShiftBits)) ThenLShift = ((lValue And m_lOnBits (31 - (iShiftBits 1))) * m_l2Power (iShiftBits)) Or & H80000000ElseLShift = ((lValue And m_lOnBits (31 - iShiftBits)) * m_l2Power (iShiftBits)) Endness Function
Private Function RShift (lValue, iShiftBits) If iShiftBits = 0 ThenRShift = lValueExit FunctionElseIf iShiftBits = 31 ThenIf lValue And & H80000000 ThenRShift = 1ElseRShift = 0End IfExit FunctionElseIf iShiftBits <0 Or iShiftBits> 31 ThenErr.Raise 6End IfRShift = (lValue And & H7FFFFFFE) / m_l2Power (iShiftBITS)
IF (Lvalue and & H80000000) THENRSHIFT = (RSHIFT OR (& H400000 / M_L2Power (IshiftBits - 1))) End IFEND Function
Private function rotateleft (Lvalue, Ishiftbits) Rotateleft = Lshift (Lvalue, IshiftBits) or Rshift (Lvalue, (32 - IshiftBits) End Function
Private function addunsigned (lx, ly) DIM LX4DIM LY4DIM LX8DIM LY8DIM LRESULT
LX8 = lx and & h80000000ly8 = ly and & h80000000lx4 = lx and & h40000000l4 = ly and & h40000000
LRESULT = (lx and & h3ffffff) (Ly and & H3FFFFFF)
If lX4 And lY4 ThenlResult = lResult Xor & H80000000 Xor lX8 Xor lY8ElseIf lX4 Or lY4 ThenIf lResult And & H40000000 ThenlResult = lResult Xor & HC0000000 Xor lX8 Xor lY8ElselResult = lResult Xor & H40000000 Xor lX8 Xor lY8End IfElselResult = lResult Xor lX8 Xor lY8End IfAddUnsigned = lResultEnd 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, 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, D), X), AC)) A = RotateLeft (A, S ) A = addunsigned (a, b) end sub
Private Function ConvertToWordArray (sMessage) Dim lMessageLengthDim lNumberOfWordsDim lWordArray () Dim lBytePositionDim lByteCountDim lWordCountConst MODULUS_BITS = 512Const CONGRUENT_BITS = 448lMessageLength = Len (sMessage) lNumberOfWords = (((lMessageLength ((MODULUS_BITS - CONGRUENT_BITS) / BITS_TO_A_BYTE)) / (MODULUS_BITS / BITS_TO_A_BYTE) ) 1) * (MODULUS_BITS / BITS_TO_A_WORD) ReDim lWordArray (lNumberOfWords - 1) lBytePosition = 0lByteCount = 0Do Until lByteCount> = lMessageLengthlWordCount = lByteCount / BYTES_TO_A_WORDlBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTElWordArray (lWordCount) = lWordArray (lWordCount) Or LShift ( Asc (Mid (sMessage, lByteCount 1, 1)), lBytePosition) lByteCount = lByteCount 1LooplWordCount = lByteCount / BYTES_TO_A_WORDlBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
LWordArray (lwordcount) = lwordArray (lwordcount) or lshift (& H80, lbyteposition)
LWordArray (lnumberofwords - 2) = lshift (LMESSAGALELENGTH, 3) LWORDARRAY (Lnumberofwords - 1) = Rshift (LMessageLength, 29) ConvertToWordArray = LWORDARRAYEND FUNCTION
Private Function WordToHex (lValue) Dim lByteDim lCountFor lCount = 0 To 3lByte = RShift (lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits (BITS_TO_A_BYTE - 1) WordToHex = WordToHex & Right ( "0" & Hex (lByte), 2) NextEnd Function
Public Function MD5 (SMESSAGE) M_LONBITS (0) = clng (1) m_lonbits (1) = ClNG (3) M_Lonbits (2) = ClNG (7) M_LONBITS (3) = CLNG (15) M_LONBITS (4) = CLNG (31 ) m_lonbits (5) = clng (63) M_LONBITS (6) = clng (127) m_lonbits (7) = clng (255) m_lonbits (8) = CLNG (511) m_lonbits (9) = CLNG (1023) m_lonbits (10) = ClNG (2047) m_lonbits (11) = clng (4095) m_lonbits (12) = clng (8191) m_lonbits (13) = clng (16383) M_LONBITS (14) = CLNG (32767) m_lonbits (15) = CLNG (65535) m_lonbits (16) = CLNG (131071) m_lonbits (17) = CLNG (262143) m_lonbits (18) = CLNG (524287) M_LONBITS (19) = CLNG (1048575) M_LONBITS (20) = CLNG (2097151) m_lonbits (21) = CLng (4194303) m_lOnBits (22) = CLng (8388607) m_lOnBits (23) = CLng (16777215) m_lOnBits (24) = CLng (33554431) m_lOnBits (25) = CLng (67108863) m_lOnBits (26) = CLng (134217727) m_lOnBits (27) = CLNG (268435455) M_LONBITS (28) = CLNG (536870911) M_LONBITS (29) = ClNG (1073741823) M_Lonbits (30) = CLNG (2147483647) M_L2Power (0) = clng (1) m_l2power (1) = CLNG (2) m_l2power (2) = clng (4) m_l2power (3) = clng (8) m_l2power (4) = CLNG (16) M_L2Power (5) = CLNG (32 ) m_l2power (6) = clng (64) m_l2power (7) = clng (128) m_l2power (8) = clng (256) m_l2power (9) = CLNG (512) m_l2power (10) = CLNG (1024) M_L2Power (11) = CLNG (2048) m_l2power (12) = clng (4096) m_l2power (13) = clng (8192) m_l2power (14) = clng (16384) m_l2power (15) = CLNG (32768) m_l2power (16) = clng (65536) m_l2power (17) = clng (131072) m_l2power (18) = clng (262144) m_l2power (19) = CLNG (524288) m_l2power (20) = clng (1048576) m_l2power (21) = clng (2097152) m_l2power (22) = CLNG (4194304) M_L2Power (23) = CLNG (8388608) M_L2POWER (24) =
CLng (16777216) m_l2Power (25) = CLng (33554432) m_l2Power (26) = CLng (67108864) m_l2Power (27) = CLng (134217728) m_l2Power (28) = CLng (268435456) m_l2Power (29) = CLng (536870912) m_l2Power (30) = CLng (1073741824) Dim xDim kDim AADim BBDim CCDim DDDim aDim bDim cDim dConst S11 = 7Const S12 = 12Const S13 = 17Const S14 = 22Const S21 = 5Const S22 = 9Const S23 = 14Const S24 = 20Const S31 = 4Const S32 = 11Const S33 = 16Const S34 = 23Const S41 = 6Const S42 = 10Const S43 = 15const S44 = 21
X = convertToWordArray (SMESSAGE) A = & H67452301B = & hefcdab89c = & h98badcfed = & h10325476
For K = 0 to Ubound (x) Step 16aa = ABB = BCC = CDD = DMD5_FF A, B, C, D, X (K 0), S11, & HD76AA478MD5_FF D, A, B, C, X (k 1 ), S12, & HE8C7B756MD5_FF C, D, A, B, X (K 2), S13, & H242070DBMD5_FF B, C, D, A, X (K 3), S14, & HC1BDCEEEMD5_FF A, B, C, D, X (k 4), S11, & HF57C0FAFMD5_FF D, A, B, C, X (K 5), S12, & H4787C62AMD5_FF C, D, A, B, X (K 6), S13, & HA8304613MD5_FF B, C, D , A, X (k 7), S14, & HFD469501MD5_FF A, B, C, D, X (K 8), S11, & H698098D8MD5_FF D, A, B, C, X (k 9), S12, & H8B44F7AFMD5_FF C , D, A, B, X (K 10), S13, & HFFFF5BB1MD5_FF B, C, D, A, X (K 11), S14, & H895CD7BEMD5_FF A, B, C, D, X (K 12), S11, & H6B901122MD5_FF D, A, B, C, X (K 13), S12, & HFD987193MD5_FF C, D, A, B, X (K 14), S13, & HA679438EMD5_FF B, C, D, A, X (K 15), S14, & H49B40821MD5_GG A, B, C, D, X (K 1), S21, & HF61E2562MD5_GG D, A, B, C, X (K 6), S22, & HC040B340MD5_GG C, D, A, B , X (k 11), S23, & H265E5A51MD5_GG B, C, D, A, X (K 0), S24, & HE9B6C7AAMD5_GG A, B, C, D, X (K 5), S21, & HD62F105DMD5_GG D, A , B, C, X (k 10), S22, & H2441453MD5_GG C, D, A, B, X (K 15), S23, & HD8A1E681MD5_GG B, C, D, A, X (K 4), S24, & HE7D3FBC8MD5_GG A, B, C, D, X (K 9), S21, & H21E1CDE6MD5_GG D, A, B, C, X (K 14), S22, & HC33707D6MD5_GG C, D, A, B, X (K 3), S23 & HF4D50D87MD5_GG B, C, D, A, X (K 8), S24, & H455A14EDMD5_GG A, B, C, D, X (K 13), S21, & HA9E3E905MD5_GG D, A, B, C, X (K 2), S22, & HFCEFA3F8MD5_GG C, D, A, B, X (K 7), S23, & H676F02D9MD5_GG B, C, D, A, X (K 12), S24, &
H8D2A4C8AMD5_HH A, B, C, D, X (K 5), S31, & HFFA3942MD5_HH D, A, B, C, X (K 8), S32, & H8771F681MD5_HH C, D, A, B, X (K 11 ), S33, & H6D9D6122MD5_HH B, C, D, A, X (K 14), S34, & HFDE5380CMD5_HH A, B, C, D, X (K 1), S31, & HA4BEEA44MD5_HH D, A, B, C, X (k 4), S32, & H4BDECFA9MD5_HH C, D, A, B, X (K 7), S33, & HF6BB4B60MD5_HH B, C, D, A, X (K 10), S34, & HBebfbc70md5_hh A, B, C , D, X (k 13), S31, & H289B7EC6MD5_HH D, A, B, C, X (K 0), S32, & HEAA127FAMD5_HH C, D, A, B, X (K 3), S33, & HD4EF3085MD5_HH B , C, D, A, X (K 6), S34, & H4881D05MD5_HH A, B, C, D, X (K 9), S31, & HD9D4D039MD5_HH D, A, B, C, X (K 12), S32, & HE6DB99E5MD5_HH C, D, A, B, X (K 15), S33, & H1FA27CF8MD5_HH B, C, D, A, X (K 2), S34, & HC4AC5665MD5_II A, B, C, D, X (K 0), S41, & HF4292244MD5_II D, A, B, C, X (K 7), S42, & H432AFF97MD5_II C, D, A, B, X (K 14), S43, & HAB9423A7MD5_II B, C, D, A X (k 5), S44, & HFC93A039MD5_II A, B, C, D, X (K 12), S41, & H655B59C3MD5_II D, A, B, C, X (K 3), S42, & H8F0CCC92MD5_II C, D , A, B, X (K 10), S43, & HFFEFF47DMD5_II B, C, D, A, X (K 1), S44, & H85845DD1MD5_II A, B, C, D, X (K 8), S41, & H6FA87E4FMD5_II D, A, B, C, X (K 15), S42, & HFE2CE6E0MD5_II C, D, A, B, X (k 6), S43, & HA3014314MD5_II B, C, D, A, X (K 13), S44 & H4E0811A1MD5_II A, B, C, D, X (K 4), S41, & HF7537E82MD5_II D, A, B, C, X (K 11), S42, & HBD3AF235MD5_II C, D, A, B, X (K 2), S43, & H2AD7D2BBMD5_II B, C, D, A, X (k 9), S44, & HEB86D391A = AddUnsigned (A, AA) B = AddunSigned (b, bb) c =
Addunsigned (C, CC) D = AddunSigned (D, DD) NextMD5 = LCase (Wordtohex (a) & WordTohex (B) & WordTohex (C) & WordToHex (D)) 'MD5 = LCase (WordTohex (B) & WordTohex ( c)) 'i crop this to fit 16byte database password: dend functionResponse.write "123456 encrypted result is [" & MD5 ("123456") & "]"%>