package com.itheima.session.app3;
import java.security.MessageDigest;
import sun.misc.BASE64Encoder;
public class MDUtil {
//拿数据指纹
public static String encoding(String message){
try{
MessageDigest md=MessageDigest.getInstance("md5");
byte []b=md.digest(message.getBytes());
//把b转换成名为:base64编码(把3个字节转换成4个字节,不足的前面补0)
BASE64Encoder base64=new BASE64Encoder();
return base64.encode(b);
}catch(Exception e){
throw new RuntimeException(e);
}
}
}
|
|