MD5算法详述及python实现

md5的输入为512位的倍数,输出为128位。

首先填充消息,使其长度为与448模512同余,即长度为512的倍数减64。填充的消息第一位为1,之后全部为0。

需要注意的是,即使原消息长度刚好为与448模512同余,仍需要填充;即使原消息长度刚好为512的整数倍,仍需要填充。

再将这剩余64位填充为原来消息的长度(二进制),若是原来消息的长度大于64位(2的64次方),如原消息的长度为70位(2的70次方),则忽略高6位的数据,只填充低64位(即长度L mod 2的64次方)。

之后序列长度就为512的倍数了,这里每一个512位称为一个分组,又将每一个512为分为16个32位,称为一个子分组(M0~M15)。

之后进行4轮运算,每一轮进行16次操作,分别针对这16个子分组。

原消息有几个分组就行进几次循环,循环这4轮运算,每次循环需要一个128位序列当“种子”,之后输出一个128位的序列,这个序列与下一分组继续作用产生下一次的128位输出。第一次循环时128位序列初始化为4个32(十六进制)位变量:A=01234567h;B=89abcdefh;C=fedcba98h;D=76543210h,注意这些变量在内存中的顺序是低值存放低字节,所以在程序中应该是:A=0x67452301;B=0xefcdab89;C=0x98badcfe;D=0x10325476.最后的一个分组产生的128位输出进行逆操作即为最终输出。(有点拗口,可以对照图片,或看代码...)


下面来具体说说每次循环的4轮运算。

这四轮运算需要用到一个常数表,这些常数T[i](i=1~64)等于4294967296*abs(sin(i))所得结果的整数部分,其中i用弧度表示。这样做是为了通过正弦函数和幂函数来进一步消除变换中的线性。

T[1] 0xd76aa478
T[2]
0xe8c7b756
T[3]
0x242070db
T[4]
0xc1bdceee
T[5]
0xf57c0faf
T[6]
0x4787c62a
T[7]
0xa8304613
T[8]
0xfd469501
T[9]
0x698098d8
T[10]
0x8b44f7af
T[11]
0xffff5bb1
T[12]
0x895cd7be
T[13]
0x6b901122
T[14]
0xfd987193
T[15]
0xa679438e
T[16]
0x49b40821
T[17]
0xf61e2562
T[18]
0xc040b340
T[19]
0x265e5a51
T[20]
0xe9b6c7aa
T[21]
0xd62f105d
T[22]
0x02441453
T[23]
0xd8a1e681
T[24]
0xe7d3fbc8
T[25]
0x21e1cde6
T[26]
0xc33707d6
T[27]
0xf4d50d87
T[28]
0x455a14ed
T[29]
0xa9e3e905
T[30]
0xfcefa3f8
T[31]
0x676f02d9
T[32]
0x8d2a4c8a
T[33]
0xfffa3942
T[34]
0x8771f681
T[35]
0x6d9d6122
T[36]
0xfde5380c
T[37]
0xa4beea44
T[38]
0x4bdecfa9
T[39]
0xf6bb4b60
T[40]
0xbebfbc70
T[41]
0x289b7ec6
T[42]
0xeaa127fa
T[43]
0xd4ef3085
T[44]
0x04881d05
T[45]
0xd9d4d039
T[46]
0xe6db99e5
T[47]
0x1fa27cf8
T[48]
0xc4ac5665
T[49]
0xf4292244
T[50]
0x432aff97
T[51]
0xab9423a7
T[52]
0xfc93a039
T[53]
0x655b59c3
T[54]
0x8f0ccc92
T[55]
0xffeff47d
T[56]
0x85845dd1
T[57]
0x6fa87e4f
T[58]
0xfe2ce6e0
T[59]
0xa3014314
T[60]
0x4e0811a1
T[61]
0xf7537e82
T[62]
0xbd3af235
T[63]
0x2ad7d2bb
T[64]
0xeb86d391

首先,应当将初始输入ABCD存起来:

INPUT_A = A

INPUT_B = B

INPUT_C = C

INPUT_D = D

第一轮:(注:公式中的<<<表示循环左移)

用到的函数:F(X,Y,Z) =(X&Y)|((~X)&Z)

A = B+((A+F(B,C,D)+M[0]+T[1])<<<7) 

D = A+((D+F(A,B,C)+M[1]+T[2])<<<12) 

C = D+((C+F(D,A,B)+M[2]+T[3])<<<17) 

B = C+((B+F(C,D,A)+M[3]+T[4])<<<22) 

A = B+((A+F(B,C,D)+M[4]+T[5])<<<7) 

D = A+((D+F(A,B,C)+M[5]+T[6])<<<12) 

C = D+((C+F(D,A,B)+M[6]+T[7])<<<17) 

B = C+((B+F(C,D,A)+M[7]+T[8])<<<22) 

A = B+((A+F(B,C,D)+M[8]+T[9])<<<7) 

D = A+((D+F(A,B,C)+M[9]+T[10])<<<12) 

C = D+((C+F(D,A,B)+M[10]+T[11])<<<17) 

B = C+((B+F(C,D,A)+M[11]+T[12])<<<22) 

A = B+((A+F(B,C,D)+M[12]+T[13])<<<7) 

D = A+((D+F(A,B,C)+M[13]+T[14])<<<12) 

C = D+((C+F(D,A,B)+M[14]+T[15])<<<17) 

B = C+((B+F(C,D,A)+M[15]+T[16])<<<22) 

第二轮:

用到的函数:G(X,Y,Z) =(X&Z)|(Y&(~Z))

A = B+((A+G(B,C,D)+M[1]+T[17])<<<5) 

D = A+((D+G(A,B,C)+M[6]+T[18])<<<9) 

C = D+((C+G(D,A,B)+M[11]+T[19])<<<14) 

B = C+((B+G(C,D,A)+M[0]+T[20])<<<20) 

A = B+((A+G(B,C,D)+M[5]+T[21])<<<5) 

D = A+((D+G(A,B,C)+M[10]+T[22])<<<9) 

C = D+((C+G(D,A,B)+M[15]+T[23])<<<14) 

B = C+((B+G(C,D,A)+M[4]+T[24])<<<20) 

A = B+((A+G(B,C,D)+M[9]+T[25])<<<5) 

D = A+((D+G(A,B,C)+M[14]+T[26])<<<9) 

C = D+((C+G(D,A,B)+M[3]+T[27])<<<14) 

B = C+((B+G(C,D,A)+M[8]+T[28])<<<20) 

A = B+((A+G(B,C,D)+M[13]+T[29])<<<5) 

D = A+((D+G(A,B,C)+M[2]+T[30])<<<9) 

C = D+((C+G(D,A,B)+M[7]+T[31])<<<14) 

B = C+((B+G(C,D,A)+M[12]+T[32])<<<20) 

第三轮:

用到的函数:H(X,Y,Z) =X^Y^Z

A = B+((A+H(B,C,D)+M[5]+T[33])<<<4) 

D = A+((D+H(A,B,C)+M[8]+T[34])<<<11) 

C = D+((C+H(D,A,B)+M[11]+T[35])<<<16) 

B = C+((B+H(C,D,A)+M[14]+T[36])<<<23) 

A = B+((A+H(B,C,D)+M[1]+T[37])<<<4) 

D = A+((D+H(A,B,C)+M[4]+T[38])<<<11) 

C = D+((C+H(D,A,B)+M[7]+T[39])<<<16) 

B = C+((B+H(C,D,A)+M[10]+T[40])<<<23) 

A = B+((A+H(B,C,D)+M[13]+T[41])<<<4) 

D = A+((D+H(A,B,C)+M[0]+T[42])<<<11) 

C = D+((C+H(D,A,B)+M[3]+T[43])<<<16) 

B = C+((B+H(C,D,A)+M[6]+T[44])<<<23) 

A = B+((A+H(B,C,D)+M[9]+T[45])<<<4) 

D = A+((D+H(A,B,C)+M[12]+T[46])<<<11) 

C = D+((C+H(D,A,B)+M[15]+T[47])<<<16) 

B = C+((B+H(C,D,A)+M[2]+T[48])<<<23) 

第四轮:

用到的函数:I(X,Y,Z)=Y^(X|(~Z))

A = B+((A+I(B,C,D)+M[0]+T[33])<<<6) 

D = A+((D+I(A,B,C)+M[7]+T[34])<<<10) 

C = D+((C+I(D,A,B)+M[14]+T[35])<<<15) 

B = C+((B+I(C,D,A)+M[5]+T[36])<<<21) 

A = B+((A+I(B,C,D)+M[12]+T[37])<<<6) 

D = A+((D+I(A,B,C)+M[3]+T[38])<<<10) 

C = D+((C+I(D,A,B)+M[10]+T[39])<<<15) 

B = C+((B+I(C,D,A)+M[1]+T[40])<<<21) 

A = B+((A+I(B,C,D)+M[8]+T[41])<<<6) 

D = A+((D+I(A,B,C)+M[15]+T[42])<<<10) 

C = D+((C+I(D,A,B)+M[6]+T[43])<<<15) 

B = C+((B+I(C,D,A)+M[13]+T[44])<<<21) 

A = B+((A+I(B,C,D)+M[4]+T[45])<<<6) 

D = A+((D+I(A,B,C)+M[11]+T[46])<<<10) 

C = D+((C+I(D,A,B)+M[2]+T[47])<<<15) 

B = C+((B+I(C,D,A)+M[9]+T[48])<<<21) 

四轮运算完成后,将此时的ABCD与原始输入分别相加。

A = A + INPUT_A

B = B + INPUT_B

C = C + INPUT_C

D = D + INPUT_D

至此,一次循环就完成了,最后的输出ABCD可以作为下一次的初始输入或最终输出。

虽然,python中已经有MD5模块,但是自己做一下有助加深理解。以下是代码:

# codeing=utf-8

#引入math模块,因为要用到sin函数
import math

#定义常量,用于初始化128位变量,注意字节顺序,文中的A=0x01234567,这里低值存放低字节,即01 23 45 67,所以运算时A=0x67452301,其他类似。
#这里用字符串的形势,是为了和hex函数的输出统一,hex(10)输出为'0xA',注意结果为字符串。
A = '0x67452301'
B = '0xefcdab89'
C = '0x98badcfe'
D = '0x10325476'

#定义每轮中用到的函数。L为循环左移,注意左移之后可能会超过32位,所以要和0xffffffff做与运算,确保结果为32位。
F = lambda x,y,z:((x&y)|((~x)&z))
G = lambda x,y,z:((x&z)|(y&(~z)))
H = lambda x,y,z:(x^y^z)
I = lambda x,y,z:(y^(x|(~z)))
L = lambda x,n:(((x<<n)|(x>>(32-n)))&(0xffffffff))

#定义每轮中循环左移的位数,这里用4个元组表示,用元组是因为速度比列表快。
shi_1 = (7,12,17,22)*4
shi_2 = (5,9,14,20)*4
shi_3 = (4,11,16,23)*4
shi_4 = (6,10,15,21)*4

#定义每轮中用到的M[i]次序。
m_1 = (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)
m_2 = (1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12)
m_3 = (5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2)
m_4 = (0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9)

#定义函数,用来产生常数T[i],常数有可能超过32位,同样需要&0xffffffff操作。注意返回的是十进制的数。
def T(i):
    result = (int(4294967296*abs(math.sin(i))))&0xffffffff
    return result

#定义函数,用来将列表中的元素循环右移。原因是在每轮操作中,先运算A的值,然后是D,C,B,16轮之后右恢复原来顺序,所以只要每次操作第一个元素即可。
def shift(shift_list):
    shift_list = [shift_list[3],shift_list[0],shift_list[1],shift_list[2]]
    return shift_list

#定义主要的函数,参数为当做种子的列表,每轮用到的F,G,H,I,生成的M[],以及循环左移的位数。该函数完成一轮运算。
def fun(fun_list,f,m,shi):
    count = 0
    global Ti_count
    #引入全局变量,T(i)是从1到64循环的。
    while count<16:
        xx = int(fun_list[0],16)+f(int(fun_list[1],16),int(fun_list[2],16),int(fun_list[3],16))+int(m[count],16)+T(Ti_count)
        xx = xx&0xffffffff
        ll = L(xx,shi[count])
        fun_list[0] = hex((int(fun_list[1],16) + ll)&(0xffffffff))[:-1]
        #最后的[:-1]是为了去除类似'0x12345678L'最后的'L'
        fun_list = shift(fun_list)
        count += 1
        Ti_count += 1
        print fun_list
    return fun_list

#该函数生成每轮需要的M[],最后的参数是为了当有很多分组时,进行偏移。
def genM16(order,ascii_list,f_offset):
    ii = 0
    m16 = [0]*16
    f_offset = f_offset*64
    for i in order:
        i = i*4
        m16[ii] = '0x'+''.join((ascii_list[i+f_offset]+ascii_list[i+1+f_offset]+ascii_list[i+2+f_offset]+ascii_list[i+3+f_offset]).split('0x'))
        ii += 1
    for c in m16:
        ind = m16.index(c)
        m16[ind] = reverse_hex(c)
    return m16

#翻转十六进制数的顺序:'0x01234567' => '0x67452301'
def reverse_hex(hex_str):
    hex_str = hex_str[2:]
    hex_str_list = []
    for i in range(0,len(hex_str),2):
        hex_str_list.append(hex_str[i:i+2])
    hex_str_list.reverse()
    hex_str_result = '0x' + ''.join(hex_str_list)
    return hex_str_result

#显示结果函数,将最后运算的结果列表进行翻转,合并成字符串的操作。
def show_result(f_list):
    result = ''
    f_list1 = [0]*4
    for i in f_list:
        f_list1[f_list.index(i)] = reverse_hex(i)[2:]
        result = result + f_list1[f_list.index(i)]
    return result
    
#程序主循环
while True:
    abcd_list = [A,B,C,D]
    Ti_count = 1
    
    input_m = raw_input('msg>>>')
    
    #对每一个输入先添加一个'0x80',即'10000000'
    ascii_list = map(hex,map(ord,input_m))
    msg_lenth = len(ascii_list)*8
    ascii_list.append('0x80')

    #补充0
    while (len(ascii_list)*8+64)%512 != 0:
        ascii_list.append('0x00')

    #最后64为存放消息长度,注意长度存放顺序低位在前。
    #例如,消息为'a',则长度为'0x0800000000000000'
    msg_lenth_0x = hex(msg_lenth)[2:]
    msg_lenth_0x = '0x' + msg_lenth_0x.rjust(16,'0')
    msg_lenth_0x_big_order = reverse_hex(msg_lenth_0x)[2:]
    msg_lenth_0x_list = []
    for i in range(0,len(msg_lenth_0x_big_order),2):
        msg_lenth_0x_list.append('0x'+ msg_lenth_0x_big_order[i:i+2])         
    ascii_list.extend(msg_lenth_0x_list)
    print  ascii_list

    #对每个分组进行4轮运算
    for i in range(0,len(ascii_list)/64):

        #将最初128位种子存放在变量中,
        aa,bb,cc,dd = abcd_list

        #根据顺序产生每轮M[]列表
        order_1 = genM16(m_1,ascii_list,i)
        order_2 = genM16(m_2,ascii_list,i)
        order_3 = genM16(m_3,ascii_list,i)
        order_4 = genM16(m_4,ascii_list,i)

        #主要四轮运算,注意打印结果列表已经被进行过右移操作!
        abcd_list = fun(abcd_list,F,order_1,shi_1)
        print '--------------------------------------'
        abcd_list = fun(abcd_list,G,order_2,shi_2)
        print '--------------------------------------'
        abcd_list = fun(abcd_list,H,order_3,shi_3)
        print '--------------------------------------'
        abcd_list = fun(abcd_list,I,order_4,shi_4)
        print '--------------------------------------'

        #将最后输出与最初128位种子相加,注意,最初种子不能直接使用abcd_list[0]等,因为abcd_list已经被改变
        output_a = hex((int(abcd_list[0],16)+int(aa,16))&0xffffffff)[:-1]
        output_b = hex((int(abcd_list[1],16)+int(bb,16))&0xffffffff)[:-1]
        output_c = hex((int(abcd_list[2],16)+int(cc,16))&0xffffffff)[:-1]
        output_d = hex((int(abcd_list[3],16)+int(dd,16))&0xffffffff)[:-1]
        
        #将输出放到列表中,作为下一次128位种子
        abcd_list = [output_a,output_b,output_c,output_d]

        #将全局变量Ti_count恢复,一遍开始下一个分组的操作。
        Ti_count = 1

        #最后调用函数,格式化输出
        print 'md5>>>' + show_result(abcd_list)

输入为a,输出为:

['0x61', '0x80', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x08', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00']

注意以下结果是已经进行过右移的列表:

即[DABC],[CDAB]...

['0x10325476', '0xa56017f4', '0xefcdab89', '0x98badcfe']
['0x98badcfe', '0xf2d58361', '0xa56017f4', '0xefcdab89']
['0xefcdab89', '0xe65857a7', '0xf2d58361', '0xa56017f4']
['0xa56017f4', '0x607d9686', '0xe65857a7', '0xf2d58361']
['0xf2d58361', '0x3a9d5bcc', '0x607d9686', '0xe65857a7']
['0xe65857a7', '0xe0a07db7', '0x3a9d5bcc', '0x607d9686']
['0x607d9686', '0xd31ddc83', '0xe0a07db7', '0x3a9d5bcc']
['0x3a9d5bcc', '0xa8af6da5', '0xd31ddc83', '0xe0a07db7']
['0xe0a07db7', '0xbe580957', '0xa8af6da5', '0xd31ddc83']
['0xd31ddc83', '0xf386bea6', '0xbe580957', '0xa8af6da5']
['0xa8af6da5', '0xf5fdd933', '0xf386bea6', '0xbe580957']
['0xbe580957', '0x68493d6a', '0xf5fdd933', '0xf386bea6']
['0xf386bea6', '0x44244cf8', '0x68493d6a', '0xf5fdd933']
['0xf5fdd933', '0xd0fe9b27', '0x44244cf8', '0x68493d6a']
['0x68493d6a', '0x6360a45f', '0xd0fe9b27', '0x44244cf8']
['0x44244cf8', '0xf01e3ce2', '0x6360a45f', '0xd0fe9b27']
--------------------------------------
['0xd0fe9b27', '0x9c341767', '0xf01e3ce2', '0x6360a45f']
['0x6360a45f', '0x970ab3a9', '0x9c341767', '0xf01e3ce2']
['0xf01e3ce2', '0xe39ffd23', '0x970ab3a9', '0x9c341767']
['0x9c341767', '0x8d25cc66', '0xe39ffd23', '0x970ab3a9']
['0x970ab3a9', '0x8c444930', '0x8d25cc66', '0xe39ffd23']
['0xe39ffd23', '0x7267097a', '0x8c444930', '0x8d25cc66']
['0x8d25cc66', '0x2dacb8a3', '0x7267097a', '0x8c444930']
['0x8c444930', '0x373beab0', '0x2dacb8a3', '0x7267097a']
['0x7267097a', '0xf175e3ad', '0x373beab0', '0x2dacb8a3']
['0x2dacb8a3', '0x9d5df67e', '0xf175e3ad', '0x373beab0']
['0x373beab0', '0x87b7f475', '0x9d5df67e', '0xf175e3ad']
['0xf175e3ad', '0xc8f891b4', '0x87b7f475', '0x9d5df67e']
['0x9d5df67e', '0x93842e98', '0xc8f891b4', '0x87b7f475']
['0x87b7f475', '0xc7043b64', '0x93842e98', '0xc8f891b4']
['0xc8f891b4', '0x94a2ebee', '0xc7043b64', '0x93842e98']
['0x93842e98', '0x3745961f', '0x94a2ebee', '0xc7043b64']
--------------------------------------
['0xc7043b64', '0xbd607d1e', '0x3745961f', '0x94a2ebee']
['0x94a2ebee', '0xa6f72085', '0xbd607d1e', '0x3745961f']
['0x3745961f', '0xbf8b4f98', '0xa6f72085', '0xbd607d1e']
['0xbd607d1e', '0xdaf7f308', '0xbf8b4f98', '0xa6f72085']
['0xa6f72085', '0x35a82a7a', '0xdaf7f308', '0xbf8b4f98']
['0xbf8b4f98', '0x89e0ec97', '0x35a82a7a', '0xdaf7f308']
['0xdaf7f308', '0x5abe099c', '0x89e0ec97', '0x35a82a7a']
['0x35a82a7a', '0xcf7e60db', '0x5abe099c', '0x89e0ec97']
['0x89e0ec97', '0x75c151e2', '0xcf7e60db', '0x5abe099c']
['0x5abe099c', '0x942e0c86', '0x75c151e2', '0xcf7e60db']
['0xcf7e60db', '0xc0e6ac4', '0x942e0c86', '0x75c151e2']
['0x75c151e2', '0xcc6f5e9e', '0xc0e6ac4', '0x942e0c86']
['0x942e0c86', '0xac50e18', '0xcc6f5e9e', '0xc0e6ac4']
['0xc0e6ac4', '0x79ca7845', '0xac50e18', '0xcc6f5e9e']
['0xcc6f5e9e', '0x8a4a6356', '0x79ca7845', '0xac50e18']
['0xac50e18', '0x918f93bb', '0x8a4a6356', '0x79ca7845']
--------------------------------------
['0x79ca7845', '0xcab8fe42', '0x918f93bb', '0x8a4a6356']
['0x8a4a6356', '0x6a4daeee', '0xcab8fe42', '0x918f93bb']
['0x918f93bb', '0x36269c3f', '0x6a4daeee', '0xcab8fe42']
['0xcab8fe42', '0x1ee405eb', '0x36269c3f', '0x6a4daeee']
['0x6a4daeee', '0x982c7861', '0x1ee405eb', '0x36269c3f']
['0x36269c3f', '0x6812a362', '0x982c7861', '0x1ee405eb']
['0x1ee405eb', '0x71fc7709', '0x6812a362', '0x982c7861']
['0x982c7861', '0x893501c0', '0x71fc7709', '0x6812a362']
['0x6812a362', '0xfebd62fd', '0x893501c0', '0x71fc7709']
['0x71fc7709', '0x28936a74', '0xfebd62fd', '0x893501c0']
['0x893501c0', '0x53e33526', '0x28936a74', '0xfebd62fd']
['0xfebd62fd', '0xaa4d8ae3', '0x53e33526', '0x28936a74']
['0x28936a74', '0x52309e0b', '0xaa4d8ae3', '0x53e33526']
['0x53e33526', '0x50f422f3', '0x52309e0b', '0xaa4d8ae3']
['0xaa4d8ae3', '0x49dee633', '0x50f422f3', '0x52309e0b']
['0x52309e0b', '0xb8e94637', '0x49dee633', '0x50f422f3']
--------------------------------------
md5>>>0cc175b9c0f1b6a831c399e269772661


结果正确。

再来看看2个分组的,输入为:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

输出为:

['0x41', '0x42', '0x43', '0x44', '0x45', '0x46', '0x47', '0x48', '0x49', '0x4a', '0x4b', '0x4c', '0x4d', '0x4e', '0x4f', '0x50', '0x51', '0x52', '0x53', '0x54', '0x55', '0x56', '0x57', '0x58', '0x59', '0x5a', '0x61', '0x62', '0x63', '0x64', '0x65', '0x66', '0x67', '0x68', '0x69', '0x6a', '0x6b', '0x6c', '0x6d', '0x6e', '0x6f', '0x70', '0x71', '0x72', '0x73', '0x74', '0x75', '0x76', '0x77', '0x78', '0x79', '0x7a', '0x41', '0x42', '0x43', '0x44', '0x45', '0x46', '0x47', '0x48', '0x49', '0x4a', '0x4b', '0x4c', '0x4d', '0x4e', '0x4f', '0x50', '0x51', '0x52', '0x53', '0x54', '0x55', '0x56', '0x57', '0x58', '0x59', '0x5a', '0x61', '0x62', '0x63', '0x64', '0x65', '0x66', '0x67', '0x68', '0x69', '0x6a', '0x6b', '0x6c', '0x6d', '0x6e', '0x6f', '0x70', '0x71', '0x72', '0x73', '0x74', '0x75', '0x76', '0x77', '0x78', '0x79', '0x7a', '0x80', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x40', '0x03', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00']

['0x10325476', '0xc6c10796', '0xefcdab89', '0x98badcfe']
['0x98badcfe', '0x99a09999', '0xc6c10796', '0xefcdab89']
['0xefcdab89', '0x11067980', '0x99a09999', '0xc6c10796']
['0xc6c10796', '0x27bce07a', '0x11067980', '0x99a09999']
['0x99a09999', '0xf22e6c4e', '0x27bce07a', '0x11067980']
['0x11067980', '0xb4ac9218', '0xf22e6c4e', '0x27bce07a']
['0x27bce07a', '0xa95a2fc0', '0xb4ac9218', '0xf22e6c4e']
['0xf22e6c4e', '0xa4799506', '0xa95a2fc0', '0xb4ac9218']
['0xb4ac9218', '0x1eb3e7c1', '0xa4799506', '0xa95a2fc0']
['0xa95a2fc0', '0xa6e70cfe', '0x1eb3e7c1', '0xa4799506']
['0xa4799506', '0xca27520b', '0xa6e70cfe', '0x1eb3e7c1']
['0x1eb3e7c1', '0x8a7612ec', '0xca27520b', '0xa6e70cfe']
['0xa6e70cfe', '0x3cbdcd45', '0x8a7612ec', '0xca27520b']
['0xca27520b', '0xc9efd874', '0x3cbdcd45', '0x8a7612ec']
['0x8a7612ec', '0x17455fbf', '0xc9efd874', '0x3cbdcd45']
['0x3cbdcd45', '0x89d7fc8e', '0x17455fbf', '0xc9efd874']
--------------------------------------
['0xc9efd874', '0xe73b0bf1', '0x89d7fc8e', '0x17455fbf']
['0x17455fbf', '0x325e88e9', '0xe73b0bf1', '0x89d7fc8e']
['0x89d7fc8e', '0x20fd8f8e', '0x325e88e9', '0xe73b0bf1']
['0xe73b0bf1', '0x411c1487', '0x20fd8f8e', '0x325e88e9']
['0x325e88e9', '0x10eb59c9', '0x411c1487', '0x20fd8f8e']
['0x20fd8f8e', '0xb39c39a', '0x10eb59c9', '0x411c1487']
['0x411c1487', '0x8dc25993', '0xb39c39a', '0x10eb59c9']
['0x10eb59c9', '0x70faeaf6', '0x8dc25993', '0xb39c39a']
['0xb39c39a', '0x37a8c09a', '0x70faeaf6', '0x8dc25993']
['0x8dc25993', '0x199217b2', '0x37a8c09a', '0x70faeaf6']
['0x70faeaf6', '0x479a9250', '0x199217b2', '0x37a8c09a']
['0x37a8c09a', '0x3f3d97df', '0x479a9250', '0x199217b2']
['0x199217b2', '0xdc4e0e2f', '0x3f3d97df', '0x479a9250']
['0x479a9250', '0xd46913ec', '0xdc4e0e2f', '0x3f3d97df']
['0x3f3d97df', '0x59c74e62', '0xd46913ec', '0xdc4e0e2f']
['0xdc4e0e2f', '0x25f142e9', '0x59c74e62', '0xd46913ec']
--------------------------------------
['0xd46913ec', '0xf5dd15c6', '0x25f142e9', '0x59c74e62']
['0x59c74e62', '0x723e2047', '0xf5dd15c6', '0x25f142e9']
['0x25f142e9', '0xd9e0033', '0x723e2047', '0xf5dd15c6']
['0xf5dd15c6', '0x84194dae', '0xd9e0033', '0x723e2047']
['0x723e2047', '0x6de4904b', '0x84194dae', '0xd9e0033']
['0xd9e0033', '0xee55001', '0x6de4904b', '0x84194dae']
['0x84194dae', '0x4cbfa1d8', '0xee55001', '0x6de4904b']
['0x6de4904b', '0x5cb22646', '0x4cbfa1d8', '0xee55001']
['0xee55001', '0xf774b565', '0x5cb22646', '0x4cbfa1d8']
['0x4cbfa1d8', '0xede6e8f', '0xf774b565', '0x5cb22646']
['0x5cb22646', '0x2d3485a6', '0xede6e8f', '0xf774b565']
['0xf774b565', '0x2580a2a3', '0x2d3485a6', '0xede6e8f']
['0xede6e8f', '0x87945bd7', '0x2580a2a3', '0x2d3485a6']
['0x2d3485a6', '0x27824bd1', '0x87945bd7', '0x2580a2a3']
['0x2580a2a3', '0x270e6a89', '0x27824bd1', '0x87945bd7']
['0x87945bd7', '0x176d32e7', '0x270e6a89', '0x27824bd1']
--------------------------------------
['0x27824bd1', '0x34946395', '0x176d32e7', '0x270e6a89']
['0x270e6a89', '0xe267d287', '0x34946395', '0x176d32e7']
['0x176d32e7', '0xaaa7cf2d', '0xe267d287', '0x34946395']
['0x34946395', '0x96568b33', '0xaaa7cf2d', '0xe267d287']
['0xe267d287', '0xefc1485', '0x96568b33', '0xaaa7cf2d']
['0xaaa7cf2d', '0xc9b13eb2', '0xefc1485', '0x96568b33']
['0x96568b33', '0x18fb40d9', '0xc9b13eb2', '0xefc1485']
['0xefc1485', '0xab4dce79', '0x18fb40d9', '0xc9b13eb2']
['0xc9b13eb2', '0xdbf0865d', '0xab4dce79', '0x18fb40d9']
['0x18fb40d9', '0x67740c00', '0xdbf0865d', '0xab4dce79']
['0xab4dce79', '0xb484f132', '0x67740c00', '0xdbf0865d']
['0xdbf0865d', '0xb62723d5', '0xb484f132', '0x67740c00']
['0x67740c00', '0x26bda321', '0xb62723d5', '0xb484f132']
['0xb484f132', '0x1ab924f4', '0x26bda321', '0xb62723d5']
['0xb62723d5', '0x51c3f96a', '0x1ab924f4', '0x26bda321']
['0x26bda321', '0xed3e6c31', '0x51c3f96a', '0x1ab924f4']
--------------------------------------
md5>>>22c6028eba170cdd68d67eea6a79eb2a
['0x2aeb796a', '0x3327bf8a', '0xdd0c17ba', '0xea7ed668']
['0xea7ed668', '0x60d773a0', '0x3327bf8a', '0xdd0c17ba']
['0xdd0c17ba', '0xb3bbbab', '0x60d773a0', '0x3327bf8a']
['0x3327bf8a', '0x33880c49', '0xb3bbbab', '0x60d773a0']
['0x60d773a0', '0x67dfaf32', '0x33880c49', '0xb3bbbab']
['0xb3bbbab', '0x73cb5319', '0x67dfaf32', '0x33880c49']
['0x33880c49', '0x6ebe5e61', '0x73cb5319', '0x67dfaf32']
['0x67dfaf32', '0xa1c02162', '0x6ebe5e61', '0x73cb5319']
['0x73cb5319', '0xd2479cbf', '0xa1c02162', '0x6ebe5e61']
['0x6ebe5e61', '0xf2a1af27', '0xd2479cbf', '0xa1c02162']
['0xa1c02162', '0x80943325', '0xf2a1af27', '0xd2479cbf']
['0xd2479cbf', '0xb893ab4f', '0x80943325', '0xf2a1af27']
['0xf2a1af27', '0xfc7e2e4f', '0xb893ab4f', '0x80943325']
['0x80943325', '0xc240c8db', '0xfc7e2e4f', '0xb893ab4f']
['0xb893ab4f', '0xcc5089c', '0xc240c8db', '0xfc7e2e4f']
['0xfc7e2e4f', '0x9fc1b914', '0xcc5089c', '0xc240c8db']
--------------------------------------
['0xc240c8db', '0x56677bee', '0x9fc1b914', '0xcc5089c']
['0xcc5089c', '0xbfaba0fe', '0x56677bee', '0x9fc1b914']
['0x9fc1b914', '0x912665b0', '0xbfaba0fe', '0x56677bee']
['0x56677bee', '0x9cdf9d1b', '0x912665b0', '0xbfaba0fe']
['0xbfaba0fe', '0xed6d6a1', '0x9cdf9d1b', '0x912665b0']
['0x912665b0', '0xadfbd03e', '0xed6d6a1', '0x9cdf9d1b']
['0x9cdf9d1b', '0xb5b6ce67', '0xadfbd03e', '0xed6d6a1']
['0xed6d6a1', '0xee0fdbf3', '0xb5b6ce67', '0xadfbd03e']
['0xadfbd03e', '0xd64f4a1f', '0xee0fdbf3', '0xb5b6ce67']
['0xb5b6ce67', '0x5abd20bd', '0xd64f4a1f', '0xee0fdbf3']
['0xee0fdbf3', '0xe87e3a8b', '0x5abd20bd', '0xd64f4a1f']
['0xd64f4a1f', '0xe8656863', '0xe87e3a8b', '0x5abd20bd']
['0x5abd20bd', '0xfbb31150', '0xe8656863', '0xe87e3a8b']
['0xe87e3a8b', '0x6a89e680', '0xfbb31150', '0xe8656863']
['0xe8656863', '0xf242b5fc', '0x6a89e680', '0xfbb31150']
['0xfbb31150', '0xbe192fa6', '0xf242b5fc', '0x6a89e680']
--------------------------------------
['0x6a89e680', '0x8cac2cde', '0xbe192fa6', '0xf242b5fc']
['0xf242b5fc', '0xd4ebee29', '0x8cac2cde', '0xbe192fa6']
['0xbe192fa6', '0xd95b3468', '0xd4ebee29', '0x8cac2cde']
['0x8cac2cde', '0xa1f9c218', '0xd95b3468', '0xd4ebee29']
['0xd4ebee29', '0xc271dedb', '0xa1f9c218', '0xd95b3468']
['0xd95b3468', '0xdcc8e0eb', '0xc271dedb', '0xa1f9c218']
['0xa1f9c218', '0xc927e2b3', '0xdcc8e0eb', '0xc271dedb']
['0xc271dedb', '0x8ec40ee0', '0xc927e2b3', '0xdcc8e0eb']
['0xdcc8e0eb', '0xf24ab478', '0x8ec40ee0', '0xc927e2b3']
['0xc927e2b3', '0x7c5a2e3', '0xf24ab478', '0x8ec40ee0']
['0x8ec40ee0', '0x8dd21ea6', '0x7c5a2e3', '0xf24ab478']
['0xf24ab478', '0xd48f29f6', '0x8dd21ea6', '0x7c5a2e3']
['0x7c5a2e3', '0x27a857b0', '0xd48f29f6', '0x8dd21ea6']
['0x8dd21ea6', '0xdc959b1c', '0x27a857b0', '0xd48f29f6']
['0xd48f29f6', '0x5d8e7843', '0xdc959b1c', '0x27a857b0']
['0x27a857b0', '0x2d5a9b88', '0x5d8e7843', '0xdc959b1c']
--------------------------------------
['0xdc959b1c', '0xf2ae95ff', '0x2d5a9b88', '0x5d8e7843']
['0x5d8e7843', '0x4f0cfbc6', '0xf2ae95ff', '0x2d5a9b88']
['0x2d5a9b88', '0x53a616d9', '0x4f0cfbc6', '0xf2ae95ff']
['0xf2ae95ff', '0x7c9ac13e', '0x53a616d9', '0x4f0cfbc6']
['0x4f0cfbc6', '0x568bab3f', '0x7c9ac13e', '0x53a616d9']
['0x53a616d9', '0x47be7649', '0x568bab3f', '0x7c9ac13e']
['0x7c9ac13e', '0xb8a4e8ce', '0x47be7649', '0x568bab3f']
['0x568bab3f', '0x358f806d', '0xb8a4e8ce', '0x47be7649']
['0x47be7649', '0xbacf4cfd', '0x358f806d', '0xb8a4e8ce']
['0xb8a4e8ce', '0xabc2313d', '0xbacf4cfd', '0x358f806d']
['0x358f806d', '0x1189bee5', '0xabc2313d', '0xbacf4cfd']
['0xbacf4cfd', '0x2e9a0149', '0x1189bee5', '0xabc2313d']
['0xabc2313d', '0x1e42456a', '0x2e9a0149', '0x1189bee5']
['0x1189bee5', '0xc3e0da51', '0x1e42456a', '0x2e9a0149']
['0x2e9a0149', '0x15aa0b81', '0xc3e0da51', '0x1e42456a']
['0x1e42456a', '0xf8636ab6', '0x15aa0b81', '0xc3e0da51']
--------------------------------------
md5>>>8c0b45ac70826fd5e9e128bb53ccee


结果正确!

阅读更多
文章标签: 密码学 MD5
个人分类: python 密码学
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

MD5算法详述及python实现

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭