import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
public class test {
public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException{
String newstr=EncoderByMd5("aa");
System.out.println(newstr);
}
public static String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md5=MessageDigest.getInstance("MD5");
BASE64Encoder base64en = new BASE64Encoder();
System.out.println(md5.digest(str.getBytes("utf-8")));
String newstr=base64en.encode(md5.digest(str.getBytes("utf-8")));
return newstr;
}
}
用md5加密用户密码
最新推荐文章于 2024-02-05 18:47:41 发布