\Pop\CryptBcrypt

Bcrypt class

Summary

Methods
Properties
Constants
setSalt()
getSalt()
generateRandomString()
__construct()
setCost()
getCost()
setPrefix()
getPrefix()
create()
verify()
No public properties found
No constants found
strlen()
verifyHash()
$salt
$cost
$prefix
N/A
No private methods found
No private properties found
N/A

Properties

$salt

$salt : string

Salt

Type

string

$cost

$cost : string

Cost

Type

string

$prefix

$prefix : string

Prefix

Type

string

Methods

setSalt()

setSalt(string  $salt = null) : self

Set the salt

Parameters

string $salt

Returns

self

getSalt()

getSalt() : string

Get the salt

Returns

string

generateRandomString()

generateRandomString(integer  $length) : string

Generate a random alphanumeric string of a predefined length.

Parameters

integer $length

Returns

string

__construct()

__construct(string  $salt = null, string  $cost = '08', string  $prefix = '$2y$') : self

Constructor

Instantiate the bcrypt object.

Parameters

string $salt
string $cost
string $prefix

Throws

\Pop\Crypt\Exception

Returns

self

setCost()

setCost(string  $cost = '08') : self

Set the cost

Parameters

string $cost

Returns

self

getCost()

getCost() : string

Get the cost

Returns

string

setPrefix()

setPrefix(string  $prefix = '$2y$') : self

Set the prefix

Parameters

string $prefix

Returns

self

getPrefix()

getPrefix() : string

Get the prefix

Returns

string

create()

create(string  $string) : string

Create the hashed value

Parameters

string $string

Throws

\Pop\Crypt\Exception

Returns

string

verify()

verify(string  $string, string  $hash) : boolean

Verify the hashed value

Parameters

string $string
string $hash

Throws

\Pop\Crypt\Exception

Returns

boolean

strlen()

strlen(string  $string) : integer

Get string length

Parameters

string $string

Returns

integer

verifyHash()

verifyHash(string  $string, string  $hash) : boolean

Verify hash, timing-safe.

Credit: Anthony Ferrara's (ircmaxell) password compat library: https://github.com/ircmaxell/password_compat

Parameters

string $string
string $hash

Returns

boolean