OpenSSL create SHA hash from shell stdin

后端 未结 2 1578
心在旅途
心在旅途 2020-12-11 00:47

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


        
相关标签:
2条回答
  • 2020-12-11 01:40

    If you're using MacOS, you might stumble upon a case where the echo is ignoring the -n argument. To workaround that, call the binary directly:

    /bin/echo -n "password" | openssl sha512
    
    0 讨论(0)
  • 2020-12-11 01:47

    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.

    0 讨论(0)
提交回复
热议问题