private static int A = 0x67452301; private static int B = 0xefcdab89; private static int C = 0x98badcfe; private static int D = 0x10325476; // F(X,Y,Z) = XY v not(X) Z // #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) private static int F(int x, int y, int z) { return (((x) & (y)) | ((~x) & (z))); } // G(X,Y,Z) = XZ v Y not(Z) // #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) private static int G(int x, int y, int z) { return (((x) & (z)) | ((y) & (~z))); } // H(X,Y,Z) = X xor Y xor Z // #define H(x, y, z) ((x) ^ (y) ^ (z)) private static int H(int x, int y, int z) { return ((x) ^ (y) ^ (z)); } // I(X,Y,Z) = Y xor (X v not(Z)) // #define I(x, y, z) ((y) ^ ((x) | (~z))) private static int I(int x, int y, int z) { return ((y) ^ ((x) | (~z))); } // #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) private static int rotateLeft(int x, int n) { return (((x) << (n)) | ((x) >> (32-(n)))); } // #define FF(a, b, c, d, x, s, ac) { \ // (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int FF(int a, int b, int c, int d, int x, int s, int ac) { a += F(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; } // #define GG(a, b, c, d, x, s, ac) { \ // (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int GG(int a, int b, int c, int d, int x, int s, int ac) { a += G(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; } // #define HH(a, b, c, d, x, s, ac) { \ // (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int HH(int a, int b, int c, int d, int x, int s, int ac) { a += H(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; } // #define II(a, b, c, d, x, s, ac) { \ // (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int II(int a, int b, int c, int d, int x, int s, int ac) { a += I(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; }
MD5中的几个变换函数
猜你喜欢
转载自lobin.iteye.com/blog/2381977
今日推荐
周排行