Md5加密

来源:互联网 发布:手机放线软件 编辑:程序博客网 时间:2024/06/05 05:13
public static String md5Encrypter(String sourceStr) throws NoSuchAlgorithmException, UnsupportedEncodingException{String resultMd5 ="";MessageDigest md = MessageDigest.getInstance("MD5");md.update(sourceStr.getBytes());byte b[] = md.digest();int i;StringBuffer buf = new StringBuffer("");for (int offset = 0; offset < b.length; offset++) { i = b[offset]; if (i < 0) i += 256; if (i < 16) buf.append("0"); buf.append(Integer.toHexString(i)); }resultMd5 = buf.toString();return resultMd5;}
原创粉丝点击