package org.springblade.pay.utils;
/**
 * @Filename: SHA1.java
 * @Author：caiqf
 * @Date�?016-4-12
 */


import java.security.MessageDigest;

/**
 * @Class: SHA1.java
 * @Description:  SHA-1������
 */
public class SHA1 {
	public static String SHA1(String decript) {

		try {
			MessageDigest sha = MessageDigest.getInstance("SHA-1");

			byte[] byteArray = decript.getBytes("UTF-8");
	        byte[] md5Bytes = sha.digest(byteArray);
	        StringBuffer hexValue = new StringBuffer();
	        for (int i = 0; i < md5Bytes.length; i++) {
	            int val = ((int) md5Bytes[i]) & 0xff;
	            if (val < 16) {
	                hexValue.append("0");
	            }
	            hexValue.append(Integer.toHexString(val));
	        }
	        return hexValue.toString();

		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";

	}
}
