摘要算法的特性

  • 摘要算法的目的的将信息进行简单地摘要,将任意长的信息摘要成固定长的信息。比如MD5,将任意长的信息摘要成128位的摘要。
  • 不可逆的,将报文摘要成一段信息后,无法通过摘要信息还原会报文。
  • 冲突性。一份报文跟其他报文的摘要信息有可能是一致的,即冲突的。一般来说,摘要算法会设计得冲突性尽量小。

常用的摘要算法有:MD5、SHA(Secure Hash Algorithm)等。下面介绍MD5。

MD5

MD,全文是Message Digest,即信息摘要的意思,是常用的信息摘要算法。

它是一种不可逆的算法,也就是说,假如将一个信息MD5摘要成一串代码,将不能通过这串代码还原回原来的信息。

使用的场景

出于这种特性,MD5常用来校验密码是否正确、校验下载文件是否完整无损。

-> 校验密码是否正确:将用户注册的密码MD5摘要后储存起来,待用户登录时将用户录入的密码MD5摘要,对比两次摘要后的信息是否相等,相等即密码正确。(这里如果加盐会更好,见后面章节)

-> 校验下载文件是否完整无损:我们常下载开源文件资源包时,可以看到网站上提供的该资源包的MD5(比如下载POI,如图一),下载文件完毕后,可通过自己的程序或直接去一些网站上计算其MD5码,如果与官网上提供的一致,则表示文件完整无损。(图二第3行日志可见,以下程序计算的MD5码与图一的官网截图一致)

直接进行MD5是否足够,为什么要加盐

如图一可见,123456的MD5码为e10adc3949ba59abbe56e057f20f883e。一般来说,MD5摘要的结果是128位的摘要信息,然后每4位用一个16进制字符表示,所有,MD5摘要的结果一般显示为32位的16进制。

如果你的系统用MD5摘要,并且无加盐,还经常使用123456为测试密码,对这一串MD5码一定很熟悉。这一些MD5码就静静地躺在DB中待校验。

如果数据库被暴露(比如拖库),坏人得到了这些MD5码,就可以通过常用密码与其MD5码的映射关系,轻而易举地翻译出大多数密码。

所以,一般来说,我们需要对原始密码进行加盐,所谓加盐,就是按照一定规则扰乱原有字符串,然后再进行MD5摘要。这个规则,自己定义,并且一定保密。

调用Spring工具类获取MD5码

目前Spring应用广泛,我们就直接使用Spring的api获取MD5码了。

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.15.RELEASE</version>
</dependency>
package com.nicchagil.md5study;

import org.springframework.util.DigestUtils;

public class MD5UtilBySpring {

    /**
* 使用MD5作信息摘要,并以十六进制表示
*/
public static String md5(byte[] bytes) {
return DigestUtils.md5DigestAsHex(bytes);
} /**
* 使用MD5作信息摘要,并以十六进制表示
*/
public static String md5(String s) {
if (s == null || s.length() == 0) {
return null;
}
return MD5UtilBySpring.md5(s.getBytes());
} }
package com.nicchagil.md5study;

public class Salter {

    public static final String PREFIX = "HOW";
public static final String FILLING = "ARE";
public static final Integer FILLING_INDEX = 5;
public static final String POSTFIX = "YOU!"; public static String salt(String source) {
if (source == null || source.length() == 0) {
return null;
} StringBuffer sb = new StringBuffer(source);
if (sb.length() > FILLING_INDEX) {
sb.insert(FILLING_INDEX, FILLING);
} return sb.insert(0, PREFIX).append(POSTFIX).toString();
} }
package com.nicchagil.md5study;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream; import org.junit.Test; public class HowToUse { @Test
public void test() throws Exception {
String source = "123456";
String md5Hex = MD5UtilBySpring.md5(source);
System.out.println(source + "'s hex md5 -> " + md5Hex);
} @Test
public void test2() throws Exception {
File file = new File("d:/poi-bin-3.13-20150929.tar.gz"); FileInputStream fis = null;
ByteArrayOutputStream baos = null;
try {
fis = new FileInputStream(file);
baos = new ByteArrayOutputStream(); byte[] bytes = new byte[1024];
int size = 0;
while ((size = fis.read(bytes)) != -1) {
if (size == 1024) {
baos.write(bytes);
} else {
baos.write(bytes, 0, size);
}
} byte[] resultBytes = baos.toByteArray();
System.out.println("size -> " + resultBytes.length);
String md5Hex = MD5UtilBySpring.md5(resultBytes);
System.out.println("Hex md5 -> " + md5Hex);
} finally {
if (fis != null) {
fis.close();
}
if (baos != null) {
baos.close();
}
}
} @Test
public void test3() throws Exception {
String source = "123456";
String saltSource = Salter.salt(source);
String md5 = MD5UtilBySpring.md5(saltSource);
System.out.println(source + " salt -> " + saltSource + " MD5 -> " + md5); source = "12345";
saltSource = Salter.salt(source);
md5 = MD5UtilBySpring.md5(saltSource);
System.out.println(source + " salt -> " + saltSource + " MD5 -> " + md5); source = "1234";
saltSource = Salter.salt(source);
md5 = MD5UtilBySpring.md5(saltSource);
System.out.println(source + " salt -> " + saltSource + " MD5 -> " + md5);
} }

图一

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZcAAABRCAIAAACRwnxHAAAN1UlEQVR4nO2dPXLcOBCFWeV7OPUBlDHzNXQARnuDDVzKHLl4galSlU+wCXMnShWrGHkTJwqdqrDBDMluoF8D4Iw85Oz7SoEHBBo/BN40wGG7CYQQsmeaazeAEELOgipGCNk3GRX7Sggh2waq2LUbRgghRRgqdu0mEUJIBVQxQsi+iVXs2u0hhJA6qGKEkH3TUMIIIbuGKkYI2TdnqNjh6TWEEF6fDu/TtNVcqmHKzj8vIYQQXv7ZRtsIIRO+ip3WnGJegNdckCdNsZpV2rC8LF1CxeJiVDFCLk2Zip0W4WlJbmAJRi1Z07BKWbqQihFCLk2ViumPtquyeEnTyk0duujK69M/T68hhNeXF1Xd169Qn5JkqRaxvxM5bq9Ph8SXe306xI0RKZkO6saIlni1aIdWNC3qT1odIUSxxhfTmqYW+fGis21SlyJ9e306xOqEXJlU3EROWUfUg9REvNdDiqM6qOuHKoZrUf03PhSPJyGk/lws9aTSY6NEfJJzLNNpSpKOxYzVC1Xs9emgbMwVJ0byJ1beuZj8uFbFPMnOjCchZKbKF9MLr1TFJiFRn5CKyQyOC1Lsi+H97EVUzFCjYhVzB5cqRkgplSomEwpVzHFibJmacjwdr5pLt+pcTGdBDx3pixGyT+pUTH0uVDGtDthCWqt17YT9jNI6sDNKpU6hXQp30HzMYdo981yMKkZIlj9xLqZU6TWvYt5pVpwhadVX098x84lrxtND9PjCqdG86teSfUZpfCKESLb5BhJ+skgIIZpNqhhFjBBSzAZVbNIw/jyKEFLABlWMEEIqoIoRQvYNVYwQsm+oYoSQfUMVI4Tsm8z/DU4IIRuHKkYI2TdUMULIvqGKEU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bF/d0I1Iqe3XXLlHvVlSWsjP/9OPilpKsecpabkqG+0/zY8mr6WzCqAglzKQPfvSYK6aQWXNXZKXD90L0aUwwndgcI4M0NwPvwd3FOclF+cjQ/K9UVBcwAV8kEu7KdNf4b6l2eodpWbs0OzHzH7R8lIkf5BcldsB6JnplxWX1CqglzwW3mlatRjppkbrYpZzCFKyVFLXrf/rCSoDdIrueKZ4/+rTabjLpiEk9SXpy6CB3Dzcu0j+XQqMMjBdnkmeSzQhyVr7Sw3tgOrL9CHJ5U1zedO98f6hymoOtqFlJuoLxyHFeTAdbzVsj9ET81PmJKcts5PwV9OCHJh1gKvQlyFYiXXCHLLbydHZeunSoF/LgnqJq8vyBXtwnOpOB2YQLeNTAZHmCSznahsFQ9DFzBZPAiW+6fc+qGcQ59qJwY7e7PcTC6bbD+iQc4+vjo41z+TZzHTLrjcRLvjtYaCXHHtfjs9OScVY77RcDOjn17JFdPJ8DYwxvFtwF9OjlqEjeR2ZWMpw9l1+PQkqLbAbJAD7RIHObJwKZ7f/s/nl4LBb/9HLsgV9oz8qjEImmSbYT/tkJNqo1a5oR26+hGzP0lGSvVncli5TE9cbqLdE7vh380HJU1lKDmqE/du+1drI6an2Ylx/99HpcOHJkHd6fnwhHzU6mpVfN1nQ9V+EdeXJAUl/kbLZX7C/KqSfCgP9Gz1UyiH6QOH3c5yqR26+xGx/40kI2X6B3K62oWUG/nbeid5o/kvBjn8gr1ahttN8d7knBBfgJv07NKVHPUE+/NtJahncH0ZMQkq+8AEKxro73bfbfLMhTkoq6/9ooBoit2BJu3EL7qcoOBDG6gn6aeBHOq3bCjoKhfb4al+VNt/TiYjZfqzdmy1S1Ru5G8gxmU+pPou9MfgQgghhkVBTgghxLAoyAkhhBgWBTkhhBDDoiAnhBBiWBTkhBBCDIuCnBBCiGFRkBNCCDEsCnJCCCGG5f8B/a4M95Fri6AAAAAASUVORK5CYII=" alt="" />

【Java】聊聊常用的摘要算法,比如MD5的更多相关文章

  1. password学4——Java 加密解密之消息摘要算法(MD5 SHA MAC)

    Java 加密解密之消息摘要算法(MD5 SHA MAC) 消息摘要 消息摘要(Message Digest)又称为数字摘要(Digital Digest). 它是一个唯一相应一个消息或文本的固定长度 ...

  2. 2.Java 加解密技术系列之 MD5

    Java 加解密技术系列之 MD5 序 背景 正文 结束语 序 上一篇文章中,介绍了最基础的编码方式 — — BASE64,也简单的提了一下编码的原理.这篇文章继续加解密的系列,当然也是介绍比较基础的 ...

  3. Java编码算法和摘要算法

    编码算法 编码算法是将一种形式转换成等价的另外一种形式.主要是为了方便某种特定场景的处理. 字母如何在计算机中表示呢? 用ASCII编码 那中文字符如何在计算机中表示呢? 用Unicode编码 如何同 ...

  4. java中常用的工具类(一)

    我们java程序员在开发项目的是常常会用到一些工具类.今天我汇总了一下java中常用的工具方法.大家可以在项目中使用.可以收藏!加入IT江湖官方群:383126909 我们一起成长 一.String工 ...

  5. java中常用的数据加密算法

    以下为加密的工具类: import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; im ...

  6. 添砖加瓦:几种常见的数据摘要算法(MD5、CRC32、SHA1和SHA256)

    1.算法概述 数据摘要算法是密码学算法中非常重要的一个分支,它通过对所有数据提取指纹信息以实现数据签名.数据完整性校验等功能,由于其不可逆性,有时候会被用做敏感信息的加密.数据摘要算法也被称为哈希(H ...

  7. Java中常用的七个阻塞队列介绍第一篇

    Java中常用的七个阻塞队列介绍第一篇 在上一篇我们对Java中的队列分类做了简单的介绍.本文咱们主要来聊聊阻塞队列中的七个常用子类.这七个阻塞队列的学习步骤:先看源码,分析完源码之后,我们再来对每个 ...

  8. Java的常用对象①②

    Java的常用对象① Java的常用对象有很多,这里只对lang包中常用的Object,Date(Calendar,DateFormat,Math),System,Runtime进行介绍.㈠Objec ...

  9. Java中常用的查找算法——顺序查找和二分查找

    Java中常用的查找算法——顺序查找和二分查找 神话丿小王子的博客 一.顺序查找: a) 原理:顺序查找就是按顺序从头到尾依次往下查找,找到数据,则提前结束查找,找不到便一直查找下去,直到数据最后一位 ...

随机推荐

  1. linux第5天 socket api

    IPv4套接口地址结构通常也称为“网际套接字地址结构”,它以“sockaddr_in”命名,定义在头文件<netinet/in.h>中 通用地址结构用来指定与套接字关联的地址.以socka ...

  2. nginx、fastCGI、php-fpm关系梳理(转载 http://blog.sina.com.cn/s/blog_6df9fbe30102v57y.html)

        前言: Linux下搭建nginx+php+memached(LPMN)的时候,nginx.conf中配需要配置fastCGI,php需要安装 php-fpm扩展并启动php-fpm守护进程, ...

  3. openssh设置免密码登录远程服务器

    主机 host | 远程机器 server 目标:从host登录到server,免密码输入 host机器: ssh-keygen -t rsa 在~/.ssh/中会生成两个文件 id_rsa.pub和 ...

  4. 夺命雷公狗jquery---5可见选择器

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. php file_get_contents与curl性能比较

    1.fopen /file_get_contents 每次请求都会重新做DNS查询,并不对 DNS信息进行缓存.但是CURL会自动对DNS信息进行缓存.对同一域名下的网页或者图片的请求只需要一次DNS ...

  6. 形状特征提取-Hu不变矩(转载)

    [原文部分转载]:http://blog.csdn.net/wrj19860202/archive/2011/04/16/6327094.aspx 在连续情况下,图像函数为 ,那么图像的p+q阶几何矩 ...

  7. ipseccmd命令解析

    IPSec 首先需要指出的是,IPSec和TCP/IP筛选是不同的东西,大家不要混淆了.TCP/IP筛选的功能十分有限,远不如IPSec灵活和强大.下面就说说如何在命令行下控制IPSec. XP系统用 ...

  8. 使用git和github托管个人项目

    1.  安装 cygwin 和 cygwin 下的 git , 测试 git 命令可用;   参考: https://cygwin.com/install.html 2.  注册 github 账号: ...

  9. 使用 Delphi Xe 的 TDictionary

    原本一直使用 TList, 将定义的一个个 Record 保存在TList 里面, 为了能把某些对象管理起来, 例如一个类的 n 多实例,可以进行索引.查找.释放等 今天刚看到原来已经有了一个叫 TD ...

  10. cronolog日志切割

    1. 下载安装 cronolog,它的主页 http://cronolog.org . 下载的是源码,安装过程就是 ./configure, make, make install,最后一步可直接把 s ...