Class OpenSsl
OpenSSL 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.
Namespace: Cake\Utility\Crypto
Constants
-
string
METHOD_AES_256_CBC ¶'aes-256-cbc'
Method Summary
-
decrypt() public static
Decrypt a value using AES-256.
-
encrypt() public static
Encrypt a value using AES-256.
Method Detail
decrypt() ¶ public static
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.
Returns
string
Throws
InvalidArgumentException
On invalid data or key.
encrypt() ¶ public static
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.
Returns
string
Throws
InvalidArgumentException
On invalid data or key.