基于J2ME的MD5算法类
{ abyte0[k] = (byte)(int)(al[j] & 255L); abyte0[k + 1] = (byte)(int)(al[j] >>> 8 & 255L); abyte0[k + 2] = (byte)(int)(al[j] >>> 16 & 255L); abyte0[k + 3] = (byte)(int)(al[j] >>> 24 & 255L); j++; } } private void Decode(long al[], byte abyte0[], int i) { int j = 0; for(int k = 0; k < i; k += 4) { al[j] = b2iu(abyte0[k]) | b2iu(abyte0[k + 1]) << 8 | b2iu(abyte0[k + 2]) << 16 | b2iu(abyte0[k + 3]) << 24; j++; } } public static long b2iu(byte byte0) { return byte0 >= 0 ? byte0 : byte0 & 0xff; } public static String byteHEX(byte byte0) {//字节到十六进制的ASCII码转换 char ac[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; char ac1[] = new char[2]; ac1[0] = ac[byte0 >>> 4 & 0xf]; ac1[1] = ac[byte0 & 0xf]; String s = new String(ac1); return s; } public static String toMD5(String s) { MD5 md5 = new MD5(); return md5.getMD5ofStr(s); } }
本新闻共 6页,当前在第 6页 1 2 3 4 5 6 | |