【Java】MD5加密

package sdfg;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class sdfg {
    
    public static String createMD5(String pw) throws NoSuchAlgorithmException
    {
        MessageDigest md;
        md=MessageDigest.getInstance("MD5");
        md.update(pw.getBytes());
        String re=new BigInteger(1,md.digest()).toString(16);                
        return re;        
    }
    
    public static void main(String[] args) throws NoSuchAlgorithmException 
    {
        String pw="asdfaf";
        
        System.out.println(createMD5(pw));
    }
}

 

转载于:https://www.cnblogs.com/tiandsp/p/7467830.html

你可能感兴趣的:(【Java】MD5加密)