Overview

Namespaces

  • PHP
  • PHPassLib
    • Application
    • Exception
    • Hash
    • Test
      • Application
      • Hash

Classes

  • BCrypt
  • BSDiCrypt
  • DESCrypt
  • MD5Crypt
  • PBKDF2
  • Portable
  • SHA1Crypt
  • SHA256Crypt
  • SHA512Crypt
  • Overview
  • Namespace
  • Class
  • Tree

Class PBKDF2

PBKDF2-SHA1/256/512 Module

This module provides three hash schemes compatible with Python PassLib's pbkdf2_<digest> schemes. PBKDF2-SHA512 is recommended for new applications.

See http://packages.python.org/passlib/lib/passlib.hash.pbkdf2_digest.html for more details about this hash scheme.

The PBKDF2 specification uses the HMAC variant of the SHA-1 hash function, which is not vulnerable to any of the known SHA-1 weaknesses. Any of the three digests are perfectly safe to use.

Supported parameters:

  • digest: Must be one of sha1, sha256, or sha512. Defaults to sha512.
  • rounds: Optional number of rounds to use. Must be an integer between 1 and 4294967296 inclusive. Defaults to 12000.
  • saltSize: Optional number of bytes to use when generating new salts. Must be an integer between 0 and 1024 inclusive. Defaults to 16.
  • salt: Optional salt string. If provided, it must be a string between 0 and 1024 characters in length. It is highly recommended that this parameter be left blank, in which case the library will generate a suitable salt for you.

This module requires the HASH Message Digest Framework extension to be loaded in order to work.

PHPassLib\Hash\PBKDF2 implements PHPassLib\Hash
Namespace: PHPassLib\Hash
Package: PHPassLib\Hashes
Copyright: Copyright (c) 2012, Ryan Chouinard
License: License - http://www.opensource.org/licenses/mit-license.php
Author: Ryan Chouinard <rchouinard@gmail.com>
Located at src/PHPassLib/Hash/PBKDF2.php
Methods summary
public static string
# genConfig( array $config = array () )

Generate a config string from an array.

Generate a config string from an array.

Parameters

$config
array
$config Array of configuration options.

Returns

string
Configuration string.

Throws

PHPassLib\Exception\InvalidArgumentException
Throws an InvalidArgumentException if any passed-in configuration options are invalid.

Implementation of

PHPassLib\Hash::genConfig()
public static array
# parseConfig( string $config )

Parse a config string into an array.

Parse a config string into an array.

Parameters

$config
string
$config Configuration string.

Returns

array
Array of configuration options or false on failure.

Implementation of

PHPassLib\Hash::parseConfig()
public static string
# genHash( string $password, string $config )

Generate a password hash using a config string.

Generate a password hash using a config string.

Parameters

$password
string
$password Password string.
$config
string
$config Configuration string.

Returns

string
Returns the hash string on success. On failure, one of *0 or *1 is returned.

Throws

PHPassLib\Exception\RuntimeException
Throws a RuntimeException if the required HASH Message Digest Framework is not not loaded.

Implementation of

PHPassLib\Hash::genHash()
public static string
# hash( string $password, string|array $config = array () )

Generate a password hash using a config string or array.

Generate a password hash using a config string or array.

Parameters

$password
string
$password Password string.
$config
string|array
$config Optional config string or array of options.

Returns

string
Returns the hash string on success. On failure, one of *0 or *1 is returned.

Throws

PHPassLib\Exception\InvalidArgumentException
Throws an InvalidArgumentException if any passed-in configuration options are invalid.
PHPassLib\Exception\RuntimeException
Throws a RuntimeException if the required HASH Message Digest Framework is not not loaded.

Implementation of

PHPassLib\Hash::hash()
public static boolean
# verify( string $password, string $hash )

Verify a password against a hash string.

Verify a password against a hash string.

Parameters

$password
string
$password Password string.
$hash
string
$hash Hash string.

Returns

boolean
Returns true if the password matches, false otherwise.

Implementation of

PHPassLib\Hash::verify()
protected static string
# genSalt( string $input = null )

Parameters

$input
string
$input

Returns

string
protected static string
# hashPbkdf2( string $password, string $salt, integer $rounds = 12000, integer $keyLength = 64, string $digest = 'sha512' )

Implementation of the PBKDF2 algorithm.

Implementation of the PBKDF2 algorithm.

Parameters

$password
string
$password Password string.
$salt
string
$salt Salt string.
$rounds
integer
$rounds Number of rounds to use.
$keyLength
integer
$keyLength Desired length of key.
$digest
string
$digest Digest to use.

Returns

string
Returns the raw byte string of the derived key.

Throws

PHPassLib\Exception\RuntimeException
Throws a RuntimeException if the required HASH Message Digest Framework is not not loaded.
protected static boolean
# validateOptions( array $options )

Parameters

$options
array
$options

Returns

boolean

Throws

PHPassLib\Exception\InvalidArgumentException
Constants summary
string DIGEST_SHA1 'sha1'
#
string DIGEST_SHA256 'sha256'
#
string DIGEST_SHA512 'sha512'
#
PHP Password Library API documentation generated by ApiGen 2.8.0