OpenSSL 从 shell 标准输入创建 SHA 哈希 [英] OpenSSL create SHA hash from shell stdin

查看:19
本文介绍了OpenSSL 从 shell 标准输入创建 SHA 哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to generate the SHA-512 hash with OpenSSL from command line without using a file?

我已经试过了

echo "password" | openssl dgst -sha512

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

but the hash looks wrong (compared with http://hash.online-convert.com/sha512-generator).

推荐答案

尝试 echo -n "password".

发生的事情是 echo 添加到字符串末尾的新行字符被散列.-necho 会抑制这种行为.

What's happening is the new line character(s) that echo adds to the end of the string are getting hashed. The -n to echo suppresses this behavior.

这篇关于OpenSSL 从 shell 标准输入创建 SHA 哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆