class Algorithms (View source)

Cryptographic algorithms

Right now this class provides a PHP based PBKDF2 implementation.

Methods

static string
pbkdf2(string $password, string $salt, int $iterationCount, int $derivedKeyLength, string $algorithm = 'sha256')

Compute a derived key from a password based on PBKDF2

Details

static string pbkdf2(string $password, string $salt, int $iterationCount, int $derivedKeyLength, string $algorithm = 'sha256')

Compute a derived key from a password based on PBKDF2

See PKCS #5 v2.0 http://tools.ietf.org/html/rfc2898 for implementation details. The implementation is tested with test vectors from http://tools.ietf.org/html/rfc6070 .

If https://wiki.php.net/rfc/hash_pbkdf2 is ever part of PHP we should check for the existence of hash_pbkdf2() and use it if available.

Parameters

string $password

Input string / password

string $salt

The salt

int $iterationCount

Hash iteration count

int $derivedKeyLength

Derived key length

string $algorithm

Hash algorithm to use, see hash_algos(), defaults to sha256

Return Value

string

The computed derived key as raw binary data