PHP Class Dcrypt\Cryptobase

Datei anzeigen Open project: dopecode/dcrypt

Protected Methods

Method Description
checksum ( string $cyphertext, string $iv, string $key, string $cipher = 'rijndael-128', string $mode = 'cbc', string $algo = 'sha256' ) : string Create a message authentication checksum.
checksumVerify ( string $calculated, string $supplied ) Verify checksum during decryption step and throw error if mismatching.
key ( string $password, string $iv, integer $cost, string $cipher = 'rijndael-128', string $mode = 'cbc', string $algo = 'sha256' ) : string Transform password into key and perform iterative HMAC (if specified)

Private Methods

Method Description
hashNormalize ( string $hash, integer $size, string $algo ) : string This will normalize a hash to a certain length by extending it if too short and truncating it if too long. This ensures that any hash algo will work with any combination of other settings. However, it is probably best to make sure that the keysize and algo size are identical so that the input hash passes through unchanged.

Method Details

checksum() protected static method

Create a message authentication checksum.
protected static checksum ( string $cyphertext, string $iv, string $key, string $cipher = 'rijndael-128', string $mode = 'cbc', string $algo = 'sha256' ) : string
$cyphertext string Cyphertext that needs a checksum.
$iv string Initialization vector.
$key string HMAC key
$cipher string Cipher string
$mode string Cipher mode string
$algo string Hashing algorithm to use for internal operations
return string

checksumVerify() protected static method

Verify checksum during decryption step and throw error if mismatching.
protected static checksumVerify ( string $calculated, string $supplied )
$calculated string
$supplied string

key() protected static method

Transform password into key and perform iterative HMAC (if specified)
protected static key ( string $password, string $iv, integer $cost, string $cipher = 'rijndael-128', string $mode = 'cbc', string $algo = 'sha256' ) : string
$password string Encryption key
$iv string Initialization vector
$cost integer Number of HMAC iterations to perform on key
$cipher string Mcrypt cipher
$mode string Mcrypt block mode
$algo string Hashing algorithm to use for internal operations
return string