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 BCrypt

BCrypt Module

BCrypt is based on a version of the Blowfish stream cipher, and features a variable number of rounds and a large salt. BCrypt is recommended for new applications.

Supported parameters:

  • rounds: Optional number of rounds to use. Must be an integer between 4 and 31 inclusive. This value is logarithmic, meaning the actual number of rounds will be 2^<rounds>. Defaults to 12.
  • ident: Identifier which specifies the version of the algorithm to use. The default of 2a is correct for most uses, but the following values are supported: 2a, 2y, 2x. For more information on what these mean, see http://php.net/security/crypt_blowfish.php.
  • salt: Optional salt string. If provided, it must be a 22 character string containing only characters in the regex range [./0-9A-Za-z]. It is highly recommended that this parameter be left blank, in which case the library will generate a suitable salt for you.

This module uses PHP's native crypt() function, which has had native support for BCrypt since 5.3.0. PHP 5.3.7 introduced support for the 2x and 2y identifiers, and applications running on older versions will not be able to use the ident parameter with these values.

PHPassLib\Hash\BCrypt 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/BCrypt.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.

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.

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 boolean
# validateOptions( array $options )

Parameters

$options
array
$options

Returns

boolean

Throws

PHPassLib\Exception\InvalidArgumentException
PHP Password Library API documentation generated by ApiGen 2.8.0