A compatibility library for the PHP 5.5 function hash_pbkdf2().
- Available as Composer package eloquent/pbkdf2-compat.
This library provides a forwards-compatible implementation of the hash_pbkdf2() function introduced in PHP 5.5. It allows the use of this function in versions of PHP prior to 5.5, and falls back to the native function when it is available.
See the PHP manual entry.
Although the documentation does not specify, the $length parameter refers to the resulting string length, not the length of the raw hash. This means that when $raw_output is false, $length needs to be doubled to produce a hash containing the same amount of data (because hex encoding doubles the number of bytes in the result string).
Inspired by ircmaxell/password_compat. PBKDF2 implementation derived from Symfony's Pbkdf2PasswordEncoder.