<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Townes &#187; 减少使用MD5</title>
	<atom:link href="https://thetownes.coolpage.biz/?feed=rss2&#038;tag=%E5%87%8F%E5%B0%91%E4%BD%BF%E7%94%A8md5" rel="self" type="application/rss+xml" />
	<link>https://thetownes.coolpage.biz</link>
	<description>本站已转移至：http://www.thetownes.info</description>
	<lastBuildDate>Thu, 01 Aug 2013 11:49:56 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2</generator>
		<item>
		<title>为什么应该放弃或减少使用MD5</title>
		<link>https://thetownes.coolpage.biz/?p=100</link>
		<comments>https://thetownes.coolpage.biz/?p=100#comments</comments>
		<pubDate>Tue, 09 Jul 2013 14:19:11 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[零碎的资料]]></category>
		<category><![CDATA[减少使用MD5]]></category>

		<guid isPermaLink="false">http://thetownes.coolpage.biz/?p=100</guid>
		<description><![CDATA[MD5即Message-Digest Algorithm 5（信息-摘要算法 5 &#8230; <a href="https://thetownes.coolpage.biz/?p=100">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>MD5即Message-Digest Algorithm 5（信息-摘要算法 5），是网络上广泛使用的散列（Hash）算法之一，可以实现将任意长度的数值映射为固定长度的较小数值。</p>
<p>MD5是一种常用的单向Hash算法。它被广泛用于以下几个用途：</p>
<p><strong>1、检查数据是否一致。</strong>将两地存储的数据进行哈希，比较结果，如果结果一致就无需再进行数据比对。这是利用了其“抵抗冲突”(collision- resistant)的能力，两个不同的数据，其哈希值只有很小的几率一致。相当多数据服务，尤其是网盘服务，利用类似的做法来检测重复数据，避免重复上传。</p>
<p><strong>2、存储用户密码。</strong>将密码哈希后的结果存储在数据库中，以做密码匹配。这是利用了其做为单向哈希的特点，从计算后的哈希值不能得到密码。</p>
<p><strong>3、校验数据正确性。</strong>将数据和数据哈希后的结果一并传输，用于检验传输过程中数据是否有损坏。这是利用了很难找到两个不同的数据，其哈希结果一致的特点。</p>
<p>下面我们将说明为什么对于上面三种用途, MD5都不适用。</p>
<p>第一个用途尤其可怕。这个用途的最大的问题是，MD5在现实中已经被发现有相当多的数据都可能导致冲突。<a href="http://marc-stevens.nl/research/md5-1block-collision/md5-1block-collision.pdf" target="_blank">举例而言</a>，如下两段数据的MD5哈希值就是完全一样的。</p>
<blockquote><p>&nbsp;&nbsp;&nbsp; 数据 1</p>
<p>4d c9 68 ff 0e e3 5c 20 95 72 d4 77 7b 72 15 87<br />
d3 6f a7 b2 1b dc 56 b7 4a 3d c0 78 3e 7b 95 18<br />
af bf a2 00 a8 28 4b f3 6e 8e 4b 55 b3 5f 42 75<br />
93 d8 49 67 6d a0 d1 55 5d 83 60 fb 5f 07 fe a2</p>
<p>数据 2</p>
<p>4d c9 68 ff 0e e3 5c 20 95 72 d4 77 7b 72 15 87<br />
d3 6f a7 b2 1b dc 56 b7 4a 3d c0 78 3e 7b 95 18<br />
af bf a2 02 a8 28 4b f3 6e 8e 4b 55 b3 5f 42 75<br />
93 d8 49 67 6d a0 d1 d5 5d 83 60 fb 5f 07 fe a2</p>
<p>输出相同的MD5 哈希</p>
<p>008ee33a9d58b51cfeb425b0959121c9</p></blockquote>
<p>这意味着，如果用户提供数据 1，服务器已经存储数据 2。通过简单的MD5哈希方式检查重复，服务器上为用户保存的数据就是2。 接下来发生的事情大家都知道了，就是用户数据丢了！</p>
<p>第二个用途很容易遭到rainbow table攻击，和明文存储密码的实质区别不大。更详细的分析可以察看<a href="http://www.williamlong.info/archives/3224.html" target="_blank">这篇文章</a>。</p>
<p>第三个用途里一般会在需要哈希的数据中混入某些秘密，也就是计算公式为md5(secret key + data)。 但这样并不适合用于验证数据的完整性。这是因为，从理论上上来说，如果知道md5(secret key +X)，即使不知道secret key的内容, 仍然可能通过对X的分析，计算得到md5(secret key +Y），从而将X成功的替换成Y，导致接收方仍然认为数据是正确的。</p>
<p>转自 月光博客</p>
]]></content:encoded>
			<wfw:commentRss>https://thetownes.coolpage.biz/?feed=rss2&#038;p=100</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
