Java String 转化成 MD5 byte[]

public static byte[] hexStringToByte(String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i < len; i++) { int pos = i * 2; result[i] = (byte) (toByte(achar[pos]) << 4 | toByte(achar[pos + 1])); } return result; } private static byte toByte(char c) { byte b = (byte) "0123456789abcdef".indexOf(c); return b; }
posted @ 2011-05-05 10:09  跳刀的兔子  阅读(1186)  评论(0编辑  收藏  举报