Example 1 — Derive a Key from a Password
A fixed salt and iteration count give a repeatable key. Real code uses a random salt and many more rounds.
<?php
$key = hash_pbkdf2('sha256', 'password', 'salt-value', 1000, 0);
echo $key, PHP_EOL; How It Works
- Pass the password and salt. The salt makes keys unique.
- Set the rounds. 1000 is for demo speed only.
- Use length 0. You get the full 64 hex characters.
- Run again. The same inputs give the same key.

