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

encryptObject()

encryptObject(object|\stdClass  $object) : string

Encrypts the serialized value of the given object.

Parameters

object|\stdClass $object

The object for encryption.

Throws

\Exception

Validation errors.

Returns

string —

The encrypted serialized object as a string.

decryptObject()

decryptObject(string  $cipherData) : object|\stdClass

Decrypts the encrypted value of the given object.

Parameters

string $cipherData

The encrypted serialized object as a string.

Throws

\Exception

Validation errors.

Returns

object|\stdClass —

The decrypted and unserialized object.

encryptFile()

encryptFile(string  $filename) : string

Encrypts the content of a given plain file.

Parameters

string $filename

The full path and name of the file for encryption.

Throws

\Exception

Validation errors.

Returns

string —

The encrypted file content.

decryptFile()

decryptFile(string  $filename) : string

Decrypts the content of a given encrypted file.

Parameters

string $filename

The full path and name of the file for encryption.

Throws

\Exception

Validation errors.

Returns

string —

The decrypted file content.

__construct()

__construct() 

Stream cipher algorithm constructor.

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.

__debugInfo()

__debugInfo() : array

Get debug information for the class instance.

Returns

array —

Debug information.

encryptData()

encryptData(string  $plainData) : string

Encrypts the given plain data.

Parameters

string $plainData

The plain input string.

Throws

\Exception

Validation errors.

Returns

string —

The cipher/encrypted data.

decryptData()

decryptData(string  $cipherData) : string

Decrypts the given cipher data.

Parameters

string $cipherData

The encrypted input string.

Throws

\Exception

Validation errors.

Returns

string —

The decrypted/plain data.

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.

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.