首页>代码>spring mvc+Resteasy+Mybatis+Ehcache整合开发java webservice接口示例demo>/springmvcResteasyMybatisEhcache/src/main/java/com/uniware/encry/util/MD5Util.java
package com.uniware.encry.util; import java.security.MessageDigest; public class MD5Util { public static String getMD5Code(String username) { try { byte[] btInput = username.getBytes(); MessageDigest mdInst = MessageDigest.getInstance("MD5"); mdInst.update(btInput); byte[] md = mdInst.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < md.length; i++) { int val = ((int) md[i]) & 0xff; if (val < 16) sb.append("0"); sb.append(Integer.toHexString(val)); } return sb.toString(); } catch (Exception e) { return null; } } }
最近下载更多