ITeye博客

java中string转码md5

Cesar28 · 2015-08-27 14:09 · java技能 · 编程语言 · Markdown

不说了,直接上代码: public final static String MD5(String s) { char hexDigits={'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; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = md*; str = hexDigits; str = hexDigits; } return new String(str); } catch (Exception e) { e.printStackTrace(); return null; } }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。