添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
 * 计算文件sha256值
public class GetFileSHA256 {
    public static byte [] hashV2(String filePath) throws IOException, NoSuchAlgorithmException {
        File file = new File(filePath);
        BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        int bufferSize = 16384;
        byte [] buffer = new byte[bufferSize];
        int sizeRead = -1;
        while ((sizeRead = in.read(buffer)) != -1) {
            digest.update(buffer, 0, sizeRead);
        in.close();
        byte [] hash = null;
        hash = new byte[digest.getDigestLength()];
        hash = digest.digest();
        return hash;
    public static String toHex(byte[] data) {
        StringBuilder sb = new StringBuilder(data.length * 2);
        for (int i = 0; i < data.length; i++) {
            String hex = Integer.toHexString(data[i]);
            if (hex.length() == 1) {
                sb.append("0");
            } else if (hex.length() == 8) {
                hex = hex.substring(6);
            sb.append(hex);
        return sb.toString().toLowerCase(Locale.getDefault());
                            
java微信发送模板消息 java 微信

微信上接入平台的demo是PHP的,没得java的,所以我自己做接入的时候遇到了一点小问题。用java做带薪开发,首先就要先通过微信的接入配置,大概原理就是微信往服务器发送一些数据,然后在服务器端做一些数据的处理,再返回数据就行了。微信官方的名称是:验证服务器地址的有效性 下面是微信官方的文档: 开发者提交信息后,微信服务器将发送GET请求到填写的服务器地址URL上,GET请求携