EVP_BytesToKey — OpenSSL key & IV derivation

Reproduce the legacy EVP_BytesToKey derivation that `openssl enc` uses to turn a password into a key and IV. Pick the hash, salt, key/IV length and iteration count — it runs in your browser, so the password never leaves your device.

Derived key & IV

About this tool

EVP_BytesToKey is the legacy key-derivation function built into OpenSSL. It is what openssl enc -pass pass:… uses to turn a password into the symmetric key and IV for a cipher when you do not pass -pbkdf2. This tool reproduces that exact derivation entirely in your browser using compiled Rust (WebAssembly) — your password and salt are never sent anywhere.

How EVP_BytesToKey works

It hashes the password (and salt) repeatedly and concatenates the digests until it has enough bytes for the key and IV:

D_1 = HASH(password ‖ salt)
D_i = HASH(D_{i-1} ‖ password ‖ salt)
key ‖ iv = D_1 ‖ D_2 ‖ …   (first key_length bytes = key, next iv_length = IV)

With an iteration count greater than 1, each digest block is hashed that many times before being appended.

Inputs

The result is deterministic: identical inputs always reproduce the same key and IV.

Common uses

Notes on security

EVP_BytesToKey is a legacy KDF and is weak by modern standards: with the default count of 1 it is essentially a single hash, offering almost no resistance to brute-force. It exists for backward compatibility. For new designs use PBKDF2 (OpenSSL's -pbkdf2), scrypt, or Argon2id, always with a unique random salt and a high iteration count.

Verified against OpenSSL

This tool matches OpenSSL's output byte-for-byte. For example, openssl enc -aes-256-cbc -md sha256 -nosalt -pass pass:password -P yields the same key and IV this tool produces for password password, hash sha256, key 32, IV 16.

FAQ

Which settings match my `openssl enc` command?

Match the -md digest (OpenSSL used MD5 by default before 1.1.0, SHA-256 since), the cipher's key/IV sizes (AES-256-CBC = key 32, IV 16; AES-128-CBC = key 16, IV 16), and the iteration count (-iter N, default 1 when the flag is absent). If the command had -nosalt, leave the salt field empty.

Where do I find the salt of an OpenSSL-encrypted file?

A salted openssl enc file starts with the 8-byte magic Salted__ followed by the 8-byte salt. Dump the first 16 bytes (e.g. xxd -l 16 file.enc), take bytes 9–16 as hex, paste them into the salt field, and set the salt encoding to hex. The salt can also be given as base64 or plain utf8 text.

What are the input limits?

The combined key + IV length must be between 1 and 1024 bytes, the iteration count must be at least 1, and a hex salt needs an even number of digits. Only the four digests OpenSSL commonly used are supported: MD5, SHA-1, SHA-256, and SHA-512.

Should I use EVP_BytesToKey for new encryption?

No. With the default count of 1 it is essentially a single unsalted-or-lightly- salted hash, so it offers almost no brute-force resistance. It exists here for interoperability — decrypting old files and matching CryptoJS. For anything new, use PBKDF2 (openssl enc -pbkdf2), scrypt, or Argon2id with a random salt.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool evp-derive "The password / passphrase"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/evp-derive/?password=The%20password%20%2F%20passphrase&salt=8-byte%20salt%20%28often%20hex%29%3B%20leave%20empty%20for%20-nosalt&salt_encoding=utf8&hash=md5&key_length=32&iv_length=16&count=1&encoding=hex

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.