\Cake\Utility\CryptoMcrypt

Mcrypt implementation of crypto features for Cake\Utility\Security

This class is not intended to be used directly and should only be used in the context of Cake\Utility\Security.

Summary

Methods
Properties
Constants
rijndael()
encrypt()
decrypt()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

rijndael()

rijndael(string  $text, string  $key, string  $operation) : string

Encrypts/Decrypts a text using the given key using rijndael method.

Parameters

string $text

Encrypted string to decrypt, normal string to encrypt

string $key

Key to use as the encryption key for encrypted data.

string $operation

Operation to perform, encrypt or decrypt

Throws

\LogicException

When there are errors.

Returns

string —

Encrypted binary string data, or decrypted data depending on operation.

encrypt()

encrypt(string  $plain, string  $key) : string

Encrypt a value using AES-256.

Caveat You cannot properly encrypt/decrypt data with trailing null bytes. Any trailing null bytes will be removed on decryption due to how PHP pads messages with nulls prior to encryption.

Parameters

string $plain

The value to encrypt.

string $key

The 256 bit/32 byte key to use as a cipher key.

Throws

\InvalidArgumentException

On invalid data or key.

Returns

string —

Encrypted data.

decrypt()

decrypt(string  $cipher, string  $key) : string

Decrypt a value using AES-256.

Parameters

string $cipher

The ciphertext to decrypt.

string $key

The 256 bit/32 byte key to use as a cipher key.

Throws

\InvalidArgumentException

On invalid data or key.

Returns

string —

Decrypted data. Any trailing null bytes will be removed.