MD5信息摘要算法,md5是对称加密算法么
珠海网上副业网
MD5信息摘要算法,md5是对称加密算法么
MD5 Message-Digest Algorithm
一种被广泛使用的密码散列函数,可以产生出一个128位(16字节)的散列值(hash value)md5是什么,用于确额信息传输完整一致。
MD5算法额法额碰撞md5是什么,因此不适用于安额性认证珠海哪里有副业可以做,如SSL公开密钥认证或是数字签名等用途。
主要应用:
密码管理,电子签名,文件完整性校验
JAVA额码实现方法一:
package md5;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5One {
public static void main(String[] args) {
// 3G的大文件
String path = "e:/account.csv";
long start = System.currentTimeMillis();
String md5 = MD5One.getMD5(path);
// 20e7ba44fdbab26c74e2a7aa7336c0e7
System.out.println(md5);
System.out.println("耗时:"+(System.currentTimeMillis()-start));
}
public static String getMD5(String path) {
BigInteger bi = null;
try {
byte[] buffer = new byte[8192];
int len = 0;
MessageDigest md = MessageDigest.getInstance("MD5");
FileInputStream fis = new FileInputStream(new File(path));
while ((len = fis.read(buffer)) != -1) {
md.update(buffer, 0, len);
}
fis.close();
byte[] b = md.digest();
bi = new BigInteger(1, b);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return bi.toString(16);
}
}
方法二:
使用commons-codec工具包
package md5;
import org.apache.commons.codec.digest.DigestUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class MD5Two {
public static void main(String[] args) {
String path = "e:/account.csv";
long start = System.currentTimeMillis();
// 20e7ba44fdbab26c74e2a7aa7336c0e7
System.out.println(md5(path));
System.out.println("耗时:"+(System.currentTimeMillis()-start));
}
public static String md5(String path) {
String md5 = null;
try {
md5 = DigestUtils.md5Hex(new FileInputStream(new File(path)));
} catch (IOException e) {
e.printStackTrace();
}
// System.out.println(md5);
return md5;
}
}
同样是3G的大文件处理,方法一耗时9秒左右,方法二耗时14秒左右。
读者福利:珠海副业副业网限时额费提供情感项目创业共赢,有执行力和2小时以上空闲时间的来,加微信: 446471435 →额了解咨询 !
相关推荐
- 元课堂商机(元课堂商机)web3.0MetaForce原力元
- 元探索中(中探索历史)web3.0MetaForce原力元
- 元建筑演讲(演讲稿600字)web3.0MetaForce原力元
- 元房产跌了(房产中介)web3.0MetaForce原力元
- 元性倾(倾世元囊云)web3.0MetaForce原力元
- 政府元方案(政策)web3.0MetaForce原力元
- 元是(是主吗)web3.0MetaForce原力元
- 政府元方案(规划局)web3.0MetaForce原力元
- 购买元app(元购物)web3.0MetaForce原力元
- 元开会体会(噬元兽为什么吐出魔方)web3.0MetaForce原力元
- 网易元 瑶台(网易中心)web3.0MetaForce原力元
- 印度元赚钱(印度的飞船)web3.0MetaForce原力元
- 元是(系列之)web3.0MetaForce原力元
- 元变现方式(企业以合并方式将部资产变现)web3.0MetaForce原力元
- 元是(是主吗)web3.0MetaForce原力元
- 打造健康元(建造)web3.0MetaForce原力元
- 元诈骗兴起(诈骗的源头)web3.0MetaForce原力元
- 元诈骗兴起(诈骗发展史)web3.0MetaForce原力元
- 元开会体会(爸爸带我看体会)web3.0MetaForce原力元
- 元眼罩名称(所有星系名称)web3.0MetaForce原力元
- 元龙头(元龙头公司)web3.0MetaForce原力元
- 元建筑演讲(演讲稿600字)web3.0MetaForce原力元
- 元房产跌了(元大跌)web3.0MetaForce原力元
- 元是(系列观)web3.0MetaForce原力元
- 元是(1610)web3.0MetaForce原力元
- 元兔子团(团成员排名)web3.0MetaForce原力元
- 茅台搞元(茅台搞元)web3.0MetaForce原力元
- 元驳回(元概念)web3.0MetaForce原力元
- 元龙头(元龙头上市公司)web3.0MetaForce原力元
- 元 认知作战(认知作战元素有哪些)web3.0MetaForce原力元
- 威海元概念(元灵之前的是)web3.0MetaForce原力元
- 元平台demo(元平台)web3.0MetaForce原力元
- 购买元app(怎么买元的币)web3.0MetaForce原力元
- 元与与企业(元企业发展现状)web3.0MetaForce原力元
- 元变现方式(互联网流量变现方式)web3.0MetaForce原力元
- 元探索中(中探索历史)web3.0MetaForce原力元
- 元 富机会(富机会越来越少了)web3.0MetaForce原力元
- 元柳夜(元和多元)web3.0MetaForce原力元
- 元中犯法(10元红包算犯法吗)web3.0MetaForce原力元
- 元故事(小故事)web3.0MetaForce原力元
- 元龙头(元龙头股)web3.0MetaForce原力元
- 元投资900(元投资机会)web3.0MetaForce原力元
- 茅台搞元(茅台搞元)web3.0MetaForce原力元
- 元狐狸(狐狸系统)web3.0MetaForce原力元
- 元龙头(元龙头上市公司)web3.0MetaForce原力元
- 元房产跌了(元大跌)web3.0MetaForce原力元
- 元故事(小故事)web3.0MetaForce原力元
- 元柳夜(柳夜晴沈媚媚大)web3.0MetaForce原力元
- 威海元概念(内元概念股300556)web3.0MetaForce原力元
- 元中犯法(酒托5000元犯法吗)web3.0MetaForce原力元