package com.snake.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.buf.HexUtils;
import org.springframework.util.Assert;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Md5签名算法
*/
@Slf4j
public class Md5 {
public static String getMd5(String content){
try {
MessageDigest md = MessageDigest.getInstance("MD5");
Assert.notNull(md,"系统内部异常");
return HexUtils.toHexString(md.digest(content.getBytes()));
} catch (NoSuchAlgorithmException e) {
log.error("签名算法获取失败: "+e);
throw new RuntimeException(e);
}
}
}