菜鸟笔记
提升您的技术认知

java生成md5的两种方式-ag真人游戏

package com.pibigstar.common.utils;
import java.security.messagedigest;
/**
 * md5加密工具类
 * @author pibigstar
 *
 */
public class mymd5util {
  
	//盐,用于混交md5
	private static final string slat = "&q23***&&%%$$#@";
	public static string encrypt(string datastr) {
  
		try {
  
			datastr = datastr   slat;
			messagedigest m = messagedigest.getinstance("md5");
			m.update(datastr.getbytes("utf8"));
			byte s[] = m.digest();
			string result = "";
			for (int i = 0; i < s.length; i  ) {
  
				result  = integer.tohexstring((0x000000ff & s[i]) | 0xffffff00).substring(6);
			}
			return result;
		} catch (exception e) {
  
			e.printstacktrace();
		}
		return "";
	}
}
package com.pibigstar.common.utils;
import org.springframework.util.digestutils;
import com.pibigstar.common.constant;
/**
 * md5工具类
 * @author pibigstar
 *
 */
public class md5util {
  
	//盐,用于混交md5
	private static final string slat = "&q23***&&%%$$#@";
	/**
	 * 生成md5
	 * @param seckillid
	 * @return
	 */
	public static string getmd5(string str) {
  
		string base = str  "/" slat;
		string md5 = digestutils.md5digestashex(base.getbytes());
		return md5;
	}
}
网站地图