<p><code>md5</code>和密码在同一句话里让我毛骨悚然。。<code>md5</code>是一种单向散列函数,这意味着<em>不应该</em>对<a href="https://stackoverflow.com/questions/1240852/is-it-possible-to-decrypt-md5-hashes">"decrypt"</a>进行哈希处理。它是一个加密函数。但是,使用<a href="http://en.wikipedia.org/wiki/Rainbow_table" rel="nofollow noreferrer">rainbow table</a>(可能还有<a href="https://stackoverflow.com/questions/1240852/is-it-possible-to-decrypt-md5-hashes">other ways</a>),您可以从<code>md5</code>哈希中恢复一些常见的字符串,这使得使用<code>md5</code>加密密码的想法更加糟糕。在</p>
<p>但无论如何,答案是:</p>
<p>不,Python脚本的答案是正确的。如果您使用<code>echo -n "robots" | md5sum</code>,您将看到它们是相同的:<code>27f5e15b6af3223f1176293cd015771d</code></p>
<p>原因是<code>echo</code>将在它所响应的字符串的末尾追加一个换行符(惊喜!),添加<code>-n</code>将不会打印换行符,因此会得到正确的结果。在</p>
<p>或者,您可以简单地使用<code>md5sum -s "robots"</code>或<code>md5 -s "robots"</code>生成哈希,而不使用<code>echo</code>。在</p>
<hr/>
<p><code>echo</code>的引用:</p>
<blockquote>
<p>The echo utility writes any specified operands, separated
by single blank (<code>' '</code>) characters and followed by a newline (<code>\n</code>) character,
to the standard output.</p>
</blockquote>
<p><a href="https://security.stackexchange.com/questions/4789/most-secure-password-hash-algorithms">What password hashing algorithm to use?</a></p>