【Java】SHA加密

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("SHA");
        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="dfgdf";
        
        System.out.println(createMD5(pw));
    }
}

 

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

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