com.gitee.cliveyuan.tools.codec.MD5Tools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-tools Show documentation
Show all versions of java-tools Show documentation
Some commonly used methods in java
package com.gitee.cliveyuan.tools.codec;
import org.apache.commons.codec.digest.DigestUtils;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* MD5工具
*
* @author clive
* Created on 2018/07/24
* @since 1.0
*/
public class MD5Tools {
private MD5Tools() {
}
/**
* md5加密
*
* @param text 文本
*/
public static String md5(String text) {
return DigestUtils.md5Hex(text);
}
/**
* md5 加盐加密
*
* @param text 文本
* @param salt 盐 (密钥)
*/
public static String md5(String text, String salt) {
return md5(text + salt);
}
}