Encrypt/decrypt a file using a symmetric cipher in CBC mode then authenticate using HMAC

package Default

 Methods

Constructor

__construct() 

Decrypt a file

decrypt(string $fileIn, string $fileOut) : boolean

Parameters

$fileIn

string

$fileOut

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Returns

boolean

Encrypt then authenticate a file using HMAC

encrypt(string $fileIn, string $fileOut) : boolean

Parameters

$fileIn

string

$fileOut

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Returns

boolean

Get the cipher object

getCipher() : \Zend\Crypt\Symmetric\SymmetricInterface

Returns

\Zend\Crypt\Symmetric\SymmetricInterface

Get the cipher algorithm

getCipherAlgorithm() : string | boolean

Returns

stringboolean

Get the supported algorithms of the symmetric cipher

getCipherSupportedAlgorithms() : array

Returns

array

Get the hash algorithm for HMAC authentication

getHashAlgorithm() : string

Returns

string

Get the key

getKey() : string | null

Returns

stringnull

Get the number of iterations for Pbkdf2

getKeyIteration() : integer

Returns

integer

Get the Pbkdf2 hash algorithm

getPbkdf2HashAlgorithm() : string

Returns

string

Set the cipher object

setCipher(\Zend\Crypt\Symmetric\SymmetricInterface $cipher) 

Parameters

$cipher

\Zend\Crypt\Symmetric\SymmetricInterface

Set algorithm of the symmetric cipher

setCipherAlgorithm(string $algo) 

Parameters

$algo

string

Set the hash algorithm for HMAC authentication

setHashAlgorithm(string $hash) 

Parameters

$hash

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Set the encryption/decryption key

setKey(string $key) 

Parameters

$key

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Set the number of iterations for Pbkdf2

setKeyIteration(integer $num) 

Parameters

$num

integer

Set the hash algorithm for the Pbkdf2

setPbkdf2HashAlgorithm(string $hash) 

Parameters

$hash

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Check that input file exists and output file dont

checkFileInOut(string $fileIn, string $fileOut) 

Parameters

$fileIn

string

$fileOut

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

 Properties

 

Cipher

$cipher : \Zend\Crypt\Symmetric\SymmetricInterface

Default

 

Hash algorithm for HMAC

$hash : string

Default

'sha256'
 

Key

$key : string

Default

 

Number of iterations for Pbkdf2

$keyIteration : integer

Default

10000
 

Hash algorithm for Pbkdf2

$pbkdf2Hash : string

Default

'sha256'

 Constants

 

BUFFER_SIZE

BUFFER_SIZE = 1048576