稍微有點複雜, 好像有多種hash方式,僅會這種,用的時候整篇**copy即可。
import com.hh.framework.core.notsupportedexception;//自己框架定義的異常,可以在catch notsupportedexception異常的地方替換成自己定義的異常
public final class md5impl
public string decode(string message)
}final class md5encoder ;
private long state = new long[4]; // state (abcd)
private long count = new long[2]; // number of bits, modulo 2^64 (lsb first)
private byte buffer = new byte[64]; // input buffer
public string digesthexstr;
private byte digest = new byte[16];
static final int s11 = 7;
static final int s12 = 12;
static final int s13 = 17;
static final int s14 = 22;
static final int s21 = 5;
static final int s22 = 9;
static final int s23 = 14;
static final int s24 = 20;
static final int s31 = 4;
static final int s32 = 11;
static final int s33 = 16;
static final int s34 = 23;
static final int s41 = 6;
static final int s42 = 10;
static final int s43 = 15;
static final int s44 = 21;
protected md5encoder()
public string ge***5ofstr(string inbuf)
return digesthexstr;
}private void md5init()
private long f(long x, long y, long z)
private long g(long x, long y, long z)
private long h(long x, long y, long z)
private long i(long x, long y, long z)
private long ff(long a, long b, long c, long d, long x, long s, long ac)
private long gg(long a, long b, long c, long d, long x, long s, long ac)
private long hh(long a, long b, long c, long d, long x, long s, long ac)
private long ii(long a, long b, long c, long d, long x, long s, long ac)
private void md5update(byte inbuf, int inputlen)
index = 0;
} else
}private void md5final ()
private void md5memcpy (byte output, byte input, int outpos, int inpos, int len)
}private void md5transform (byte block)
private void encode (byte output, long input, int len)
}private void decode (long output, byte input, int len)
public static long b2iu(byte b)
public static string bytehex(byte ib) ;
char ob = new char[2];
ob[0] = digit[(ib >>> 4) & 0x0f];
ob[1] = digit[ib & 0x0f];
string s = new string(ob);
return s;}}
java實現MD5演算法
public class md5 src class md5 static final byte padding private long state private long count private byte buffer public string digesthexstr private ...
MD5演算法實現
md5.h ifndef md5 h define md5 h typedef struct md5 ctx 非線性輔助函式 define f x,y,z x y x z define g x,y,z x z y z define h x,y,z x y z define i x,y,z y x z...
MD5演算法實現
md5.h ifndef md5 h define md5 h typedef struct md5 ctx 非線性輔助函式 define f x,y,z x y x z define g x,y,z x z y z define h x,y,z x y z define i x,y,z y x z...