Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Mcrypt Class Reference

Symmetric encryption using the Mcrypt extension. More...

Public Member Functions

 __construct ($options=[])
 Constructor.
 
 setOptions ($options)
 Set default options.
 
 getKeySize ()
 Get the maximum key size for the selected cipher and mode of operation.
 
 setKey ($key)
 Set the encryption key If the key is longer than maximum supported, it will be truncated by getKey().
 
 getKey ()
 Get the encryption key.
 
 setAlgorithm ($algo)
 Set the encryption algorithm (cipher)
 
 getAlgorithm ()
 Get the encryption algorithm.
 
 setPadding (Padding\PaddingInterface $padding)
 Set the padding object.
 
 getPadding ()
 Get the padding object.
 
 encrypt ($data)
 Encrypt.
 
 decrypt ($data)
 Decrypt.
 
 getSaltSize ()
 Get the salt (IV) size.
 
 getSupportedAlgorithms ()
 Get the supported algorithms.
 
 setSalt ($salt)
 Set the salt (IV)
 
 getSalt ()
 Get the salt (IV) according to the size requested by the algorithm.
 
 getOriginalSalt ()
 Get the original salt value.
 
 setMode ($mode)
 Set the cipher mode.
 
 getMode ()
 Get the cipher mode.
 
 getSupportedModes ()
 Get all supported encryption modes.
 
 getBlockSize ()
 Get the block size.
 

Static Public Member Functions

static getPaddingPluginManager ()
 Returns the padding plugin manager.
 
static setPaddingPluginManager ($plugins)
 Set the padding plugin manager.
 

Public Attributes

const DEFAULT_PADDING = 'pkcs7'
 

Protected Member Functions

 setDefaultOptions ($options=[])
 Set default options.
 

Protected Attributes

 $key
 
 $iv
 
 $algo = 'aes'
 
 $mode = 'cbc'
 
 $padding
 
 $supportedAlgos
 
 $supportedModes
 

Static Protected Attributes

static $paddingPlugins = null
 

Detailed Description

Symmetric encryption using the Mcrypt extension.

NOTE: DO NOT USE only this class to encrypt data. This class doesn't provide authentication and integrity check over the data. PLEASE USE Zend instead!

Constructor & Destructor Documentation

__construct (   $options = [])

Constructor.

Parameters
array | Traversable$options
Exceptions
Exception\RuntimeException
Exception\InvalidArgumentException

Member Function Documentation

decrypt (   $data)

Decrypt.

Parameters
string$data
Exceptions
Exception\InvalidArgumentException
Returns
string

Implements SymmetricInterface.

encrypt (   $data)

Encrypt.

Parameters
string$data
Exceptions
Exception\InvalidArgumentException
Returns
string

Implements SymmetricInterface.

getAlgorithm ( )

Get the encryption algorithm.

Returns
string

Implements SymmetricInterface.

getBlockSize ( )

Get the block size.

Returns
int

Implements SymmetricInterface.

getKey ( )

Get the encryption key.

Returns
string

Implements SymmetricInterface.

getKeySize ( )

Get the maximum key size for the selected cipher and mode of operation.

Returns
int

Implements SymmetricInterface.

getMode ( )

Get the cipher mode.

Returns
string

Implements SymmetricInterface.

getOriginalSalt ( )

Get the original salt value.

Returns
string
getPadding ( )

Get the padding object.

Returns
Padding
static getPaddingPluginManager ( )
static

Returns the padding plugin manager.

If it doesn't exist it's created.

Returns
ContainerInterface
getSalt ( )

Get the salt (IV) according to the size requested by the algorithm.

Returns
string

Implements SymmetricInterface.

getSaltSize ( )

Get the salt (IV) size.

Returns
int

Implements SymmetricInterface.

getSupportedAlgorithms ( )

Get the supported algorithms.

Returns
array

Implements SymmetricInterface.

getSupportedModes ( )

Get all supported encryption modes.

Returns
array

Implements SymmetricInterface.

setAlgorithm (   $algo)

Set the encryption algorithm (cipher)

Parameters
string$algo
Exceptions
Exception\InvalidArgumentException
Returns
Mcrypt

Implements SymmetricInterface.

setDefaultOptions (   $options = [])
protected

Set default options.

Parameters
array$options
Returns
void
setKey (   $key)

Set the encryption key If the key is longer than maximum supported, it will be truncated by getKey().

Parameters
string$key
Exceptions
Exception\InvalidArgumentException
Returns
Mcrypt

Implements SymmetricInterface.

setMode (   $mode)

Set the cipher mode.

Parameters
string$mode
Exceptions
Exception\InvalidArgumentException
Returns
Mcrypt

Implements SymmetricInterface.

setOptions (   $options)

Set default options.

Parameters
array$options
Returns
void

Implements SymmetricInterface.

setPadding ( Padding\PaddingInterface  $padding)

Set the padding object.

Parameters
Padding\PaddingInterface$padding
Returns
Mcrypt
static setPaddingPluginManager (   $plugins)
static

Set the padding plugin manager.

Parameters
string | ContainerInterface$plugins
Exceptions
Exception\InvalidArgumentException
Returns
void
setSalt (   $salt)

Set the salt (IV)

Parameters
string$salt
Exceptions
Exception\InvalidArgumentException
Returns
Mcrypt

Implements SymmetricInterface.

Member Data Documentation

$algo = 'aes'
protected
$iv
protected
$key
protected
$mode = 'cbc'
protected
$padding
protected
$paddingPlugins = null
staticprotected
$supportedAlgos
protected
Initial value:
= [
'aes' => 'rijndael-128'
$supportedModes
protected
Initial value:
= [
'cbc' => 'cbc'
const DEFAULT_PADDING = 'pkcs7'