首页>代码>spring mvc+Apache Shiro框架验证登录demo例子>/Shiro-demo/src/main/java/com/che/util/PassWDUtil.java
package com.che.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 加密模块
 * @author admin
 *
 */
public class PassWDUtil {

	/**
	 * 对字符串进行 MD5 加密
	 * @param plainString 需要加密的字符串
	 * @return 返回加密后的字符串
	 * @throws NoSuchAlgorithmException 
	 */
	public static String MD5(String plainString){
		
		if(plainString == null)
			throw new NullPointerException();
		
		StringBuffer hexString = new StringBuffer();
		try {
			MessageDigest messageDigest = MessageDigest.getInstance("MD5");
			messageDigest.update(plainString.getBytes());
			byte[] byteData = messageDigest.digest();
			
			for (int i = 0; i < byteData.length; i++) {
				String hex = Integer.toHexString(0xff & byteData[i]);
				if (hex.length() == 1)
					hexString.append('0');
				hexString.append(hex);
			}
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		
		return hexString.toString();
	}
}
最近下载更多
阿木林  LV8 2021年6月10日
1255958892  LV2 2021年5月7日
zhujunnan  LV12 2021年1月6日
zxx886  LV2 2020年8月26日
a1677596408  LV23 2020年5月14日
liuwenlong  LV20 2020年4月21日
我要赚钱  LV6 2019年11月26日
zhangj391391  LV2 2019年11月20日
553152469  LV3 2019年11月15日
keith00  LV12 2019年8月26日
最近浏览更多
irivn007  LV15 2023年10月19日
森sdfgf  LV8 2023年6月28日
caozongan  LV19 2022年2月18日
Retasu  LV2 2021年12月24日
szf123  LV12 2021年11月13日
adasdsda  LV1 2021年9月26日
2393931995  LV1 2021年9月26日
12qq12  LV9 2021年9月15日
阿木林  LV8 2021年6月10日
wz66666  LV9 2021年6月7日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友