資源簡介
解決js和Java生成MD5值不一致問題,親自測試過,可以直接使用

代碼片段和文件信息
package?com.northking.test;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileNotFoundException;
import?java.io.IOException;
import?java.math.BigInteger;
import?java.security.MessageDigest;
import?java.security.NoSuchAlgorithmException;
public?class?MD5test?{
public?static?void?main(String[]?args)?{??
????????try?{??
????????????File?file?=?new?File(“d:/fileTest.txt“);??
????????????FileInputStream?fis?=?new?FileInputStream(file);??
????????????MessageDigest?md?=?MessageDigest.getInstance(“MD5“);??
????????????byte[]?buffer?=?new?byte[1024];??
????????????int?length?=?-1;??
????????????while?((length?=?fis.read(buffer?0?1024))?!=?-1)?{??
????????????????md.update(buffer?0?length);??
????????????}??
????????????BigInteger?bigInt?=?new?BigInteger(1?md.digest());??
????????????System.out.println(“文件md5值:“?+?bigInt.toString(16));??
????????}?catch?(FileNotFoundException?e)?{??
????????????e.printStackTrace();??
????????}?catch?(NoSuchAlgorithmException?e)?{??
????????????e.printStackTrace();??
????????}?catch?(IOException?e)?{??
????????????e.printStackTrace();??
????????}??
????}??
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-25?09:36??Jsmd5\css\
?????文件????????5981??2018-04-25?09:29??Jsmd5\css\st
?????目錄???????????0??2018-04-25?09:43??Jsmd5\js\
?????文件??????293430??2018-04-25?09:39??Jsmd5\js\jquery-1.12.4.js
?????文件????????3186??2018-04-25?09:29??Jsmd5\js\main.js
?????文件???????23958??2018-04-25?09:43??Jsmd5\js\md5.js
?????文件????????8422??2018-04-25?09:29??Jsmd5\js\syntax-highlight.js
?????文件????????1661??2018-04-25?10:43??Jsmd5\md5.html
?????文件????????1170??2018-04-24?17:25??Jsmd5\MD5test.java
- 上一篇:北大青鳥ACCP6.0S2寵物商店項目java官方最新版
- 下一篇:安卓涂鴉源程序
評論
共有 條評論