public class test { /** * MD5加密 (返回大写) * @author YANGCAIWEN * @param s * @return */ public static final String MD5ToUpperCase(String s) { char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; try { byte[] btInput = s.getBytes("UTF-8"); MessageDigest mdInst = MessageDigest.getInstance("MD5"); mdInst.update(btInput); byte[] md = mdInst.digest(); int j = md.length; char[] str = new char[j * 2]; int k = 0; for (int i = 0; i < j; ++i) { byte byte0 = md[i]; str[k++] = hexDigits[byte0 >>> 4 & 15]; str[k++] = hexDigits[byte0 & 15]; } return new String(str); } catch (Exception var10) { var10.printStackTrace(); return null; } } }
常用加密方式MD5加密并转大写
最新推荐文章于 2024-04-17 10:54:15 发布