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

 Methods

Constructor

__construct() 

Decrypt a file

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

Parameters

$fileIn

string

$fileOut

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Returns

bool

Encrypt then authenticate a file using HMAC

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

Parameters

$fileIn

string

$fileOut

string

Exceptions

\Zend\Crypt\Exception\InvalidArgumentException

Returns

bool

Get the cipher algorithm

getCipherAlgorithm() : string | bool

Returns

stringbool

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() : int

Returns

int

Get the Pbkdf2 hash algorithm

getPbkdf2HashAlgorithm() : string

Returns

string

Set the cipher object

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

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(int $num) 

Parameters

$num

int

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

   

Hash algorithm for HMAC

$hash : string

 

Key

$key : string

 

Number of iterations for Pbkdf2

$keyIteration : int

 

Hash algorithm for Pbkdf2

$pbkdf2Hash : string

 Constants

 

BUFFER_SIZE

BUFFER_SIZE