MD5加密16位(大写、小写)

相信现在程序MD5加密已经非常常见比如注册一个账号,用户的密码都需要加密的,那么是加密的字符串是大写的还是小写的呢???
不急,我这里大写小写都可以
代码走起


public class MD5Utils {public static String getMD5Str(String str) {MessageDigest messageDigest = null;try {messageDigest = MessageDigest.getInstance("MD5");messageDigest.reset();messageDigest.update(str.getBytes("UTF-8"));} catch (NoSuchAlgorithmException e) {System.out.println("NoSuchAlgorithmException caught!");System.exit(-1);} catch (UnsupportedEncodingException e) {e.printStackTrace();}byte[] byteArray = messageDigest.digest();StringBuffer md5StrBuff = new StringBuffer();for (int i = 0; i < byteArray.length; i++) {if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));elsemd5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));}//16位加密,从第9位到25位  大写
//        return md5StrBuff.substring(8, 24).toString().toUpperCase();//16位加密,从第9位到25位  小写return md5StrBuff.substring(8, 24).toString();}}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部