\Pop\CryptSha

SHA Crypt class

Summary

Methods
Properties
Constants
setSalt()
getSalt()
generateRandomString()
__construct()
setBits256()
setBits512()
getBits()
setRounds()
getRounds()
create()
verify()
No public properties found
No constants found
strlen()
verifyHash()
$salt
$bits
$rounds
N/A
No private methods found
No private properties found
N/A

Properties

$salt

$salt : string

Salt

Type

string

$bits

$bits : integer

Bits

Type

integer

$rounds

$rounds : integer

Rounds

Type

integer

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, integer  $bits = 512, integer  $rounds = 5000) : self

Constructor

Instantiate the sha object.

Parameters

string $salt
integer $bits
integer $rounds

Returns

self

setBits256()

setBits256() : self

Method to set the cost to 256 bits

Returns

self

setBits512()

setBits512() : self

Method to set the cost to 512 bits

Returns

self

getBits()

getBits() : integer

Get the bits

Returns

integer

setRounds()

setRounds(integer  $rounds = 5000) : self

Set the rounds

Parameters

integer $rounds

Returns

self

getRounds()

getRounds() : integer

Get the rounds

Returns

integer

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

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