欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

java md5工具類分享

 更新時(shí)間:2014年02月17日 11:58:02   作者:  
這篇文章主要介紹了java的md5工具類,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

import javasecurityMessageDigest;
import javasecurityNoSuchAlgorithmException;

/**
 * MD5工具類 
 *  
 * @author
 * @version 0 
 */ 
public class Md5Util {
    /** 
     * Md 
     * 
     * @param value the value 
     * @return the string 
     */ 
    public static String md5(String value) {  
        try {  
            MessageDigest md = MessageDigestgetInstance("md5");  
            byte[] e = mddigest(valuegetBytes());  
            return toHex(e);  
        }  
        catch (NoSuchAlgorithmException e) {  
            eprintStackTrace();  
            return value;  
        }  
    }  

    /** 
     * Md 
     * 
     * @param bytes the bytes 
     * @return the string 
     */ 
    public static String md5(byte[] bytes){
        try {  
            MessageDigest md = MessageDigestgetInstance("md5");  
            byte[] e = mddigest(bytes);  
            return toHex(e);  
        }  
        catch (NoSuchAlgorithmException e) {  
            e.printStackTrace();  
            return "";  
        }  
    }  

    /** 
     * To hex 
     * 
     * @param bytes the bytes 
     * @return the string 
     */ 
    private static String toHex(byte bytes[]){
        StringBuilder hs = new StringBuilder();  
        String stmp ="";
        for (int n = 0; n < byteslength; n++) {  
            stmp = IntegertoHexString(bytes[n] & 0xff);  
            if (stmplength() == 1)  
                hsappend("0")append(stmp);  
            else 
                hsappend(stmp);  
        }  
        return hstoString();  
    }  
}

相關(guān)文章

最新評(píng)論