2

How do I generate a SHA-256 hash in base64 format from commandline? I want a piped commands kind of solution.

2 Answers2

3

I suggest the following piped command:

printf InputKey | sha256sum | cut -d ' ' -f 1 | xxd -r -p | base64
0

The alternative solution is using openssl and a bit shorter:

echo -n InputKey | openssl sha256 -binary | base64 -
miklosq
  • 91