Documentation

Pbkdf2PasswordHasher
in package
implements LegacyPasswordHasherInterface Uses CheckPasswordLengthTrait

FinalYes

Pbkdf2PasswordHasher uses the PBKDF2 (Password-Based Key Derivation Function 2).

Providing a high level of Cryptographic security, PBKDF2 is recommended by the National Institute of Standards and Technology (NIST).

But also warrants a warning, using PBKDF2 (with a high number of iterations) slows down the process. PBKDF2 should be used with caution and care.

Tags
author

Sebastiaan Stok s.stok@rollerscapes.net

author

Andrew Johnson

author

Fabien Potencier fabien@symfony.com

Table of Contents

Interfaces

LegacyPasswordHasherInterface
Provides password hashing and verification capabilities for "legacy" hashers that require external salts.

Properties

$algorithm  : string
$encodedLength  : int
$encodeHashAsBase64  : bool
$iterations  : int
$length  : int

Methods

__construct()  : mixed
hash()  : string
Hashes a plain password.
needsRehash()  : bool
verify()  : bool
Checks that a plain password and a salt match a password hash.
isPasswordTooLong()  : bool

Properties

Methods

__construct()

public __construct([string $algorithm = 'sha512' ][, bool $encodeHashAsBase64 = true ][, int $iterations = 1000 ][, int $length = 40 ]) : mixed
Parameters
$algorithm : string = 'sha512'

The digest algorithm to use

$encodeHashAsBase64 : bool = true

Whether to base64 encode the password hash

$iterations : int = 1000

The number of iterations to use to stretch the password hash

$length : int = 40

Length of derived key to create

hash()

Hashes a plain password.

public hash(string $plainPassword[, string $salt = null ]) : string
Parameters
$plainPassword : string
$salt : string = null
Return values
string

needsRehash()

public needsRehash(string $hashedPassword) : bool
Parameters
$hashedPassword : string
Return values
bool

verify()

Checks that a plain password and a salt match a password hash.

public verify(string $hashedPassword, string $plainPassword[, string $salt = null ]) : bool
Parameters
$hashedPassword : string
$plainPassword : string
$salt : string = null
Return values
bool

isPasswordTooLong()

private isPasswordTooLong(string $password) : bool
Parameters
$password : string
Return values
bool

        
On this page

Search results