package com.ssj.framework.basic.utils;

import org.apache.commons.codec.digest.DigestUtils;

public class SHACoder {
	/**
	 * SHA-1消息摘要算法,返回字节数组
	 *//*
	@SuppressWarnings("deprecation")
	public static byte[] encodeSHA(byte[] data) throws Exception {
		return DigestUtils.sha(data);
	}
	
	*//**
	 * SHA-1消息摘要算法,返回十六进制字符串
	 *//*
	@SuppressWarnings("deprecation")
	public static String encodeSHAHex(byte[] data) throws Exception {
		return DigestUtils.shaHex(data);
	}
*/
	/**
	 * SHA-256消息摘要算法,返回字节数组
	 */
	public static byte[] encodeSHA256(byte[] data) throws Exception {
		return DigestUtils.sha256(data);
	}
	
	/**
	 * SHA-256消息摘要算法,返回十六进制字符串
	 */
	public static String encodeSHA256Hex(byte[] data) throws Exception {
		return DigestUtils.sha256Hex(data);
	}

	/**
	 * SHA-384消息摘要算法,返回字节数组
	 *//*
	public static byte[] encodeSHA384(byte[] data) throws Exception {
		return DigestUtils.sha384(data);
	}
	
	*//**
	 * SHA-384消息摘要算法,返回十六进制字符串
	 *//*
	public static String encodeSHA384Hex(byte[] data) throws Exception {
		return DigestUtils.sha384Hex(data);
	}
	
	*//**
	 * SHA-512消息摘要算法,返回字节数组
	 *//*
	public static byte[] encodeSHA512(byte[] data) throws Exception {
		return DigestUtils.sha512(data);
	}
	
	*//**
	 * SHA-512消息摘要算法,返回十六进制字符串
	 * (更能确保唯一，但效率更低)
	 *//*
	public static String encodeSHA512Hex(byte[] data) throws Exception {
		return DigestUtils.sha512Hex(data);
	}
	
	
	public static String encoderToMD5(String str) throws Exception {
        //MessageDigest md5 = DigestUtils.getMd5Digest();
        String newStr = DigestUtils.md5Hex(str);
        return newStr;
    }*/
}
