Constants

ALGORITHM_NAME

ALGORITHM_NAME

The internal name of the algorithm.

KEY_SIZE

KEY_SIZE

The internal secret key size measured in raw bytes length for the algorithm

Properties

$key

$key : string

The encryption/decryption secret key property storage.

Type

string — The encryption/decryption secret key string value.

$cipherFormat

$cipherFormat : integer

The output cipher format property storage.

Type

integer — The output cipher format integer code value.

Methods

setSecretKey()

setSecretKey(string  $key) : $this

Setter for the secret key string property.

Parameters

string $key

The encryption key string.

Throws

\Exception

Validation errors.

Returns

$this —

The symmetric encryption algorithm object.

getSecretKey()

getSecretKey() : string

Getter for the secret key string property.

Returns

string —

The encryption key string.

setCipherFormat()

setCipherFormat(integer  $cipherFormat) : $this

Setter for the output cipher format code property.

Parameters

integer $cipherFormat

The output cipher format code.

Throws

\Exception

Validation errors.

Returns

$this —

The encryption algorithm object.

getCipherFormat()

getCipherFormat() : integer

Getter for the output cipher format code property.

Returns

integer —

The output cipher format code.

__construct()

__construct() 

Symmetrical encryption algorithm constructor.

encryptionFormat()

encryptionFormat(string  $bytes) 

Internal method for converting format after encryption operations.

Parameters

string $bytes

The bytes for conversion.

decryptionFormatHex()

decryptionFormatHex(string  $bytes) 

Internal method for converting from HEX formatted string after decryption operations.

Parameters

string $bytes

The bytes for conversion.

decryptionFormatBase64()

decryptionFormatBase64(string  $bytes) 

Internal method for converting from Base64 formatted string after decryption operations.

Parameters

string $bytes

The bytes for conversion.

decryptionFormat()

decryptionFormat(string  $bytes) 

Internal method for converting format after decryption operations.

Parameters

string $bytes

The bytes for conversion.

changeOutputFormat()

changeOutputFormat(string  $bytes, boolean|integer|null  $direction = true) : string

Internal method for converting the output format representation via the chosen format.

Parameters

string $bytes

The bytes for conversion.

boolean|integer|null $direction

Flag for encryption direction (encrypt => true or decrypt => false).

Returns

string —

The formatted bytes.

fetchAlgorithmMethodName()

fetchAlgorithmMethodName() : string

Fetch the correctly formatted internal encryption algorithm method name.

Returns

string —

The symmetric encryption algorithm standard.

validatePlainDataForEncryption()

validatePlainDataForEncryption(string  $plainData) 

Internal method for the validation of plain data used at encryption operations.

Parameters

string $plainData

The plain input string.

Throws

\Exception

Validation errors.

validateCipherDataForDecryption()

validateCipherDataForDecryption(string  $cipherData) 

Internal method for the validation of cipher data used at decryption operations.

Parameters

string $cipherData

The encrypted input string.

Throws

\Exception

Validation errors.