\CryptoManana\Core\Interfaces\ContainersEncryptionKeyGenerationInterface

Interface EncryptionKeyGenerationInterface - Interface for encryption key and IV generation.

Summary

Methods
Constants
getEncryptionKey()
getEncryptionInitializationVector()
SECRET_KEY_128_BITS
SECRET_KEY_192_BITS
SECRET_KEY_256_BITS
IV_128_BITS
IV_192_BITS
IV_256_BITS
No protected methods found
N/A
No private methods found
N/A

Constants

SECRET_KEY_128_BITS

SECRET_KEY_128_BITS

The symmetric secret key 128-bit size.

SECRET_KEY_192_BITS

SECRET_KEY_192_BITS

The symmetric secret key 192-bit size.

SECRET_KEY_256_BITS

SECRET_KEY_256_BITS

The symmetric secret key 256-bit size.

IV_128_BITS

IV_128_BITS

The symmetric initialization vector (IV) 128-bit size.

IV_192_BITS

IV_192_BITS

The symmetric initialization vector (IV) 192-bit size.

IV_256_BITS

IV_256_BITS

The symmetric initialization vector (IV) 256-bit size.

Methods

getEncryptionKey()

getEncryptionKey(integer  $length = self::SECRET_KEY_128_BITS, boolean|integer  $printable = true) : string

Generate a random encryption key for symmetrical cyphers.

Note: The output string can be in raw bytes of the $printable parameter is set to true.

Parameters

integer $length

The desired output length (default => 16).

boolean|integer $printable

Flag for using only printable characters instead of bytes (default => true).

Returns

string —

Randomly generated encryption key.

getEncryptionInitializationVector()

getEncryptionInitializationVector(integer  $length = self::IV_128_BITS, boolean|integer  $printable = true) : string

Generate a random initialization vector (IV) for encryption purposes.

Note: The output string can be in raw bytes of the $printable parameter is set to true.

Parameters

integer $length

The desired output length (default => 16).

boolean|integer $printable

Flag for using only printable characters instead of bytes (default => true).

Throws

\Exception

Validation errors.

Returns

string —

Randomly generated encryption initialization vector.