Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
731 views
in Technique[技术] by (71.8m points)

unix - OpenSSL create SHA hash from shell stdin

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

I've tried this

echo "password" | openssl dgst -sha512

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try echo -n "password".

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...