Java MD5加密

代码如下

package com.imooc.utils;

import org.apache.commons.codec.binary.Base64;

import java.security.MessageDigest;

public class MD5Utils {

	/**
	 * 
	 * @Title: MD5Utils.java
	 * @Package com.imooc.utils
	 * @Description: 对字符串进行md5加密
	 */
	public static String getMD5Str(String strValue) throws Exception {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		String newstr = Base64.encodeBase64String(md5.digest(strValue.getBytes()));
		return newstr;
	}

	public static void main(String[] args) {
		try {
			String md5 = getMD5Str("123");
			System.out.println(md5);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-12-31
  • 2021-11-21
  • 2022-01-08
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2021-08-15
  • 2021-11-06
  • 2021-09-23
  • 2021-05-31
  • 2021-09-14
相关资源
相似解决方案