Table of contents
Namespace: Com\Tecnick\Pdf\Encrypt\Type
class AESnopad
Source: src/Type/AESnopad.php:36
AES no-padding
Constants
BLOCKSIZE
Block size (IV length): \openssl_cipher_iv_length(‘aes-256-cbc’)
public const BLOCKSIZE = 16
Source: src/Type/AESnopad.php:44
IVECT
Initialization Vector (16 bytes)
public const IVECT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Source: src/Type/AESnopad.php:51
VALID_CIPHERS
List of valid openssl cyphers for AES encryption.
public const VALID_CIPHERS = ['aes-128-cbc', 'aes-256-cbc']
Source: src/Type/AESnopad.php:58
Methods
checkCipher()
Check if the cipher is valid and available.
public checkCipher(string $cipher): void
Parameters:
$cipher(string): openSSL cipher name.
Throws:
- Exception: in case of error.
Source: src/Type/AESnopad.php:158
checkKeyLength()
Check that the key length matches the one required by the cipher.
OpenSSL zero-extends a short key and truncates a long one.
public checkKeyLength(string $key, string $cipher): void
Parameters:
$key(string): Encryption key.$cipher(string): openSSL cipher name.
Throws:
- Exception: in case of error.
Source: src/Type/AESnopad.php:179
decrypt()
Decrypt data that was produced by encrypt().
encrypt() zero-pads the plaintext to 16-byte alignment and applies no block padding, so this method decrypts with OPENSSL_ZERO_PADDING and returns the zero-padded plaintext. The caller strips any trailing zero bytes.
public decrypt(
string $data,
string $key,
string $ivect = \self::IVECT,
string $mode = 'aes-256-cbc'
): string
Parameters:
$data(string): Encrypted data (produced by encrypt()).$key(string): Encryption key.$ivect(string): Initialization vector (default: 16 zero bytes).$mode(string): Cipher (default: aes-256-cbc).
Returns: string: Decrypted data string.
Throws:
- Exception: When decryption fails.
Source: src/Type/AESnopad.php:115
encrypt()
Encrypt the data
public encrypt(
string $data,
string $key,
string $ivect = \self::IVECT,
string $mode = 'aes-256-cbc'
): string
Parameters:
$data(string): Data string to encrypt$key(string): Encryption key$ivect(string): Initialization vector$mode(string): Cipher
Returns: string: Encrypted data string.
Throws:
Source: src/Type/AESnopad.php:75