OpenSSL从shell stdin创建SHA哈希

use*_*821 17 unix shell openssl

如何在不使用文件的情况下从命令行使用OpenSSL生成SHA-512哈希?

我试过这个

echo "password" | openssl dgst -sha512
Run Code Online (Sandbox Code Playgroud)

但哈希看起来不对(与http://hash.online-convert.com/sha512-generator相比).

Dav*_*e G 24

试试echo -n "password".

发生了什么是echo添加到字符串末尾的新行字符被哈希处理.该-necho抑制这种行为.

  • 或者`openssl dgst -sha512 <<< $ password_to_hash` (3认同)