<commit_before>package com.qq.weixin.mp.aes;

import java.security.MessageDigest;
import java.util.Arrays;

/**
 * SHA1算法计算公众平台的消息签名接口
 *
 * @author Tencent
 * @since 2014/11/4
 */
public class SHA1 {

	/**
     * 用SHA1算法生成安全签名
     * @param params [token, timestamp, nonce, encrypt]
     * @return 安全签名
     * @throws com.qq.weixin.mp.aes.AesException
     */
        public static String calculate(String... params) throws AesException {
		try {
            String[] array = params;
			StringBuffer sb = new StringBuffer();
			// 字符串排序
			Arrays.sort(array);
			int len = params.length;
			for (int i = 0; i < len; i++) {
				sb.append(array[i]);
			}
			String str = sb.toString();
			// SHA1签名生成
			MessageDigest md = MessageDigest.getInstance("SHA-1");
			md.update(str.getBytes());
			byte[] digest = md.digest();

			StringBuffer hexstr = new StringBuffer();
			String shaHex = "";
			for (int i = 0; i < digest.length; i++) {
				shaHex = Integer.toHexString(digest[i] & 0xFF);
				if (shaHex.length() < 2) {
					hexstr.append(0);
				}
				hexstr.append(shaHex);
			}
			return hexstr.toString();
		} catch (Exception e) {
			throw new AesException(AesException.ComputeSignatureError);
		}
	}
}<commit_msg>更新SHA1签名算法<commit_after>package com.qq.weixin.mp.aes;

import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Formatter;

/**
 * SHA1算法计算公众平台的消息签名接口
 *
 * @author Tencent
 * @since 2014/11/4
 */
public class SHA1 {

    /**
     * 用SHA1算法生成安全签名
     *
     * @param params [token, timestamp, nonce, encrypt]
     * @return 安全签名
     * @throws com.qq.weixin.mp.aes.AesException
     */
    public static String calculate(String... params) throws AesException {
        try {
            String[] array = params;
            StringBuffer sb = new StringBuffer();
            // 字符串排序
            Arrays.sort(array);
            int len = params.length;
            for (int i = 0; i < len; i++) {
                sb.append(array[i]);
            }

            // SHA1签名生成
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            md.reset();
            md.update(new String(sb).getBytes("UTF-8"));

            // HEX输出
            byte[] hash = md.digest();
            Formatter formatter = new Formatter();
            for (byte b : hash) {
                formatter.format("%02x", b);
            }
            String hex = formatter.toString();
            formatter.close();
            return hex;
        } catch (Exception e) {
            throw new AesException(AesException.ComputeSignatureError);
        }
    }
}
{'fraction_non_alphanumeric': 0.13302397525135345, 'fraction_numerical': 0.013147718484145398, 'mean_word_length': 2.1019184652278176, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1450344', 'n_tokens_mistral': 952, 'n_tokens_neox': 886, 'n_words': 181}