zoukankan      html  css  js  c++  java
  • Java工具类-加密算法

    import java.io.UnsupportedEncodingException;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    
    public class Jiami {
    	private static String jiami=null;
    	public static String jiami(String str) throws UnsupportedEncodingException {
    		MessageDigest md;
    		try {
    			// 固定加密算法
    			md = MessageDigest.getInstance("MD5");
    			// 获取加密后的数组
    			byte[] b = md.digest(str.getBytes("utf-8"));
    			// 进行BASE64编码
    			sun.misc.BASE64Encoder base64Encoder = new sun.misc.BASE64Encoder();
    			// 将加密后的数组进行base64编码,转换成对应的字符串
    			jiami = base64Encoder.encode(b);
    		} catch (NoSuchAlgorithmException e) {
    			e.printStackTrace();
    		}
    		return jiami;
    	}
    }
    

      

  • 相关阅读:
    HDU 1060 Leftmost Digit
    HDU 1008 Elevator
    HDU 1042 N!
    HDU 1040 As Easy As A+B
    HDU 1007 Quoit Design
    欧拉函数
    HDU 4983 Goffi and GCD
    HDU 2588 GCD
    HDU 3501 Calculation 2
    HDU 4981 Goffi and Median
  • 原文地址:https://www.cnblogs.com/Roni-i/p/9917896.html
Copyright © 2011-2022 走看看