Hmac MD5的一个大文件

时间:2017-09-30 17:02:09

标签: java hmac javax.crypto

我正在使用BufferedInputStream包装的FileInputStream来读取字节块中的大文件。

public void MD5(BufferedInputStream in, Key pubKey) throws Exception{

        Mac md = Mac.getInstance("HmacMD5");
            md.init(pubKey);
            byte[] contents = new byte[1024];
            int readSize;
            while ((readSize = in.read(contents)) != -1) {
                {
                    md.update(contents,0,readSize);
                }
                byte[] hashValue = md.doFinal();

            }
}

它适用于小文件,但对于文件200MB文件需要精神错乱的时间

当我尝试使用SHA256withRSA签署200MB文件时,同样的方法完全正常。

这有什么具体原因吗?我觉得这与 md.update()有关。

但我在使用'Signature'时也使用了相同的功能。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:4)

你在while循环中调用<script src="./jquery.min.js"> //none secure web page ? jQuery.get("https://www.bitstamp.net/api/ticker/", function (data, status) { // use response here; jQuery passes it as the first parameter var response = JSON.parse(data); window.alert(response.last); console.log("MyFunc: " + "response : " + response + "\nStatus: " + status); }); </script> 。这看起来不对。请尝试以下方法:

doFinal
相关问题