2

According to Dovecot's wiki, a SHA256 scheme is the sha256 sum of the password stored in base64.

$ doveadm pw -s SHA256 -p "test"
{SHA256}n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=

but it does not match the output of this command :

$ echo -n "test" | sha256sum | awk '{ print $1 }' | base64
OWY4NmQwODE4ODRjN2Q2NTlhMmZlYWEwYzU1YWQwMTVhM2JmNGYxYjJiMGI4MjJjZDE1ZDZjMTVi
MGYwMGEwOAo=

Why is it different?

Gradient
  • 247
  • 1
  • 2
  • 6

1 Answers1

2

I found the answer. The output of

$ echo -n "test" | sha256sum

is the hex representation of the hash. sha256sum does not have an option for raw (binary) output. This command works :

$ echo -n "test" | openssl dgst -binary -sha256 | base64
Gradient
  • 247
  • 1
  • 2
  • 6