您好,欢迎访问三七文档
MD5一、定义、用途、功能二、MD5原理三、算法实现MD5(单向散列算法)的全称是Message-DigestAlgorithm5(信息-摘要算法),经MD2、MD3和MD4发展而来。防止被篡改防止直接看到明文NO.1•NO.2MD5用途•NO.3防止抵赖(数字签名)定义、用途、功能一功能1.输入任意长度的信息,经过处理,输出为128位的信息(数字指纹);2.不同的输入得到的不同的结果(唯一性);3.根据128位的输出结果不可能反推出输入的信息(不可逆);MD5原理二MD5算法步骤四轮循环运算装入标准的幻数记录信息长度填充128位的信息最初文本信息装入标准的幻数(四个整数):标准的幻数是(A=(01234567)16,B=(89ABCDEF)16,C=(FEDCBA98)16,D=(76543210)16)最初信息填充部分最初信息长度512*n+448512*(n+1)100000000064位message323232323232.......将每个512分成16块32位I(X,Y,Z)=Y^(X|(~Z))4F(X,Y,Z)=(X&Y)|((~X)&Z)1G(X,Y,Z)=(X&Z)|(Y&(~Z))2H(X,Y,Z)=X^Y^Z3四个非线性函数注:(&是与(And),|是或(Or),~是非(Not),^是异或(Xor))a=b+((a+G(b,c,d)+Mj+ti)s)a=b+((a+F(b,c,d)+Mj+ti)s)a=b+((a+H(b,c,d)+Mj+ti)s)a=b+((a+I(b,c,d)+Mj+ti)s)FF(a,b,c,d,Mj,s,ti)GG(a,b,c,d,Mj,s,ti)HH(a,b,c,d,Mj,s,ti)II(a,b,c,d,Mj,s,ti)四种操作第一轮第二轮第三轮第四轮FF(a,b,c,d,M0,7,0xd76aa478)FF(d,a,b,c,M1,12,0xe8c7b756)FF(c,d,a,b,M2,17,0x242070db)FF(b,c,d,a,M3,22,0xc1bdceee)FF(a,b,c,d,M4,7,0xf57c0faf)FF(d,a,b,c,M5,12,0x4787c62a)FF(c,d,a,b,M6,17,0xa8304613)FF(b,c,d,a,M7,22,0xfd469501)FF(a,b,c,d,M8,7,0x698098d8)FF(d,a,b,c,M9,12,0x8b44f7af)FF(c,d,a,b,M10,17,0xffff5bb1)FF(b,c,d,a,M11,22,0x895cd7be)FF(a,b,c,d,M12,7,0x6b901122)FF(d,a,b,c,M13,12,0xfd987193)FF(c,d,a,b,M14,17,0xa679438e)FF(b,c,d,a,M15,22,0x49b40821)GG(a,b,c,d,M1,5,0xf61e2562)GG(d,a,b,c,M6,9,0xc040b340)GG(c,d,a,b,M11,14,0x265e5a51)GG(b,c,d,a,M0,20,0xe9b6c7aa)GG(a,b,c,d,M5,5,0xd62f105d)GG(d,a,b,c,M10,9,0x02441453)GG(c,d,a,b,M15,14,0xd8a1e681)GG(b,c,d,a,M4,20,0xe7d3fbc8)GG(a,b,c,d,M9,5,0x21e1cde6)GG(d,a,b,c,M14,9,0xc33707d6)GG(c,d,a,b,M3,14,0xf4d50d87)GG(b,c,d,a,M8,20,0x455a14ed)GG(a,b,c,d,M13,5,0xa9e3e905)GG(d,a,b,c,M2,9,0xfcefa3f8)GG(c,d,a,b,M7,14,0x676f02d9)GG(b,c,d,a,M12,20,0x8d2a4c8a)HH(a,b,c,d,M5,4,0xfffa3942)HH(d,a,b,c,M8,11,0x8771f681)HH(c,d,a,b,M11,16,0x6d9d6122)HH(b,c,d,a,M14,23,0xfde5380c)HH(a,b,c,d,M1,4,0xa4beea44)HH(d,a,b,c,M4,11,0x4bdecfa9)HH(c,d,a,b,M7,16,0xf6bb4b60)HH(b,c,d,a,M10,23,0xbebfbc70)HH(a,b,c,d,M13,4,0x289b7ec6)HH(d,a,b,c,M0,11,0xeaa127fa)HH(c,d,a,b,M3,16,0xd4ef3085)HH(b,c,d,a,M6,23,0x04881d05)HH(a,b,c,d,M9,4,0xd9d4d039)HH(d,a,b,c,M12,11,0xe6db99e5)HH(c,d,a,b,M15,16,0x1fa27cf8)HH(b,c,d,a,M2,23,0xc4ac5665)II(a,b,c,d,M0,6,0xf4292244)II(d,a,b,c,M7,10,0x432aff97)II(c,d,a,b,M14,15,0xab9423a7)II(b,c,d,a,M5,21,0xfc93a039)II(a,b,c,d,M12,6,0x655b59c3)II(d,a,b,c,M3,10,0x8f0ccc92)II(c,d,a,b,M10,15,0xffeff47d)II(b,c,d,a,M1,21,0x85845dd1)II(a,b,c,d,M8,6,0x6fa87e4f)II(d,a,b,c,M15,10,0xfe2ce6e0)II(c,d,a,b,M6,15,0xa3014314)II(b,c,d,a,M13,21,0x4e0811a1)II(a,b,c,d,M4,6,0xf7537e82)II(d,a,b,c,M11,10,0xbd3af235)II(c,d,a,b,M2,15,0x2ad7d2bb)II(b,c,d,a,M9,21,0xeb86d391)常数ti是4294967296*abs(sin(i))的整数部分,i取值从1到64,单位是弧度。所有这些完成之后,将a、b、c、d分别在原来基础上再加上A、B、C、D。即a=a+A,b=b+B,c=c+C,d=d+D。然后用下一分组数据继续运行以上算法。MD5(messagedigest)=f96b697d7cb7938d525a2f31aaf161d0MD5(abc)=900150983cd24fb0d6963f7d28e17f72例如:算法实现三
本文标题:MD5
链接地址:https://www.777doc.com/doc-4677207 .html