用md5加密用户密码

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;
}
}

上一篇:EDAS ScheduleX 问题


下一篇:Oracle的时区问题