AESnopad

AES no-padding

Namespace: Com\Tecnick\Pdf\Encrypt\Type

File: AESnopad.php line 36

AES no-padding

Tags

Constants

BLOCKSIZE

File: AESnopad.php line 44

public int BLOCKSIZE = 16

IVECT

File: AESnopad.php line 51

public string IVECT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

VALID_CIPHERS

File: AESnopad.php line 58

public array<string|int, string> VALID_CIPHERS = ['aes-128-cbc', 'aes-256-cbc']

Methods

checkCipher()

File: AESnopad.php line 158

public checkCipher(string $cipher) : void

Parameters

  • $cipher : string: openSSL cipher name.

Tags

checkKeyLength()

File: AESnopad.php line 179

public checkKeyLength(string $key, string $cipher) : void

OpenSSL zero-extends a short key and truncates a long one.

Parameters

  • $key : string: Encryption key.
  • $cipher : string: openSSL cipher name.

Tags

decrypt()

File: AESnopad.php line 115

public decrypt(string $data, string $key[, string $ivect = self::IVECT ][, string $mode = 'aes-256-cbc' ]) : string

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.

Parameters

  • $data : string: Encrypted data (produced by encrypt()).
  • $key : string: Encryption key.
  • $ivect : string = self::IVECT: Initialization vector (default: 16 zero bytes).
  • $mode : string = ‘aes-256-cbc’: Cipher (default: aes-256-cbc).

Tags

Return values

string —

Decrypted data string.

encrypt()

File: AESnopad.php line 75

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 = self::IVECT: Initialization vector
  • $mode : string = ‘aes-256-cbc’: Cipher

Tags

Return values

string —

Encrypted data string.