0

OpenSSL can be used to calculate a hash of a file or given input from the shell, like this:

echo -n "abc" | openssl dgst -sha256
or
openssl dgst -sha256 myfile.txt

Can I also calculate a KDF value, e.g. PBKDF2 or bcrypt or scrypt or Argon2 in a similar way?

So given an input (plaintext or filename) plus the appropriate parameters like iteration count, can I get the corresponding KDF result?

Ideally I'd use openssl for this (as it's available on all platforms) but if there is another standardized tool or way of doing this, that's also fine.

RocketNuts
  • 1,342

1 Answers1

0

After some experimenting I found nettle-pbkdf2 to be commonly available on both macOS (through Homebrew) as well as Linux (through apt get).

echo -n 'MyPaSsWoRd' | nettle-pbkdf2 --iterations 500000 --length 64 --hex-salt 436d07d286c730ad

Gives a 64 byte (512 bit) PBKDF2 result, using HMAC-SHA256 as the underlying hashing function.

RocketNuts
  • 1,342