\CryptoManana\CryptographicProtocolLayeredEncryption

Class LayeredEncryption - The multiple layered encryption protocol object.

Summary

Methods
Properties
Constants
__construct()
__destruct()
__clone()
setLayers()
addLayer()
getLayers()
layeredEncryptData()
layeredDecryptData()
No public properties found
No constants found
xorTwoStrings()
validateOneTimePad()
$ciphers
N/A
No private methods found
No private properties found
N/A

Properties

Methods

__construct()

__construct(array<mixed,\CryptoManana\DataStructures\EncryptionLayer>|array  $configuration = array()) 

Container constructor.

Parameters

array<mixed,\CryptoManana\DataStructures\EncryptionLayer>|array $configuration

The layers' configuration.

Throws

\Exception

Initialization validation.

__destruct()

__destruct() 

Container destructor.

__clone()

__clone() 

Container cloning via deep copy.

setLayers()

setLayers(array<mixed,\CryptoManana\DataStructures\EncryptionLayer>|array  $layers) : $this

Setter for the encryption layers' configuration.

Parameters

array<mixed,\CryptoManana\DataStructures\EncryptionLayer>|array $layers

Collection of layers.

Throws

\Exception

Validation errors.

Returns

$this —

The cryptographic protocol object.

addLayer()

addLayer(\CryptoManana\DataStructures\EncryptionLayer  $layer) : $this

Add a single new layer at the last of the list.

Parameters

\CryptoManana\DataStructures\EncryptionLayer $layer

The layer configuration.

Throws

\Exception

Validation errors.

Returns

$this —

The cryptographic protocol object.

getLayers()

getLayers() : array<mixed,\CryptoManana\DataStructures\EncryptionLayer>|array

Getter for the encryption layers' configuration.

Throws

\Exception

Validation errors.

Returns

array<mixed,\CryptoManana\DataStructures\EncryptionLayer>|array —

Collection of used layers' configuration.

layeredEncryptData()

layeredEncryptData(string  $plainData, string  $oneTimePad = '') : string

Encrypts the given plain data multiple times with different algorithms as layers.

Parameters

string $plainData

The plain input string.

string $oneTimePad

The optional one-time pad key.

Throws

\Exception

Validation errors.

Returns

string —

The cipher/encrypted data.

layeredDecryptData()

layeredDecryptData(string  $cipherData, string  $oneTimePad = '') : string

Decrypts the given cipher data multiple times with different algorithms as layers.

Parameters

string $cipherData

The encrypted input string.

string $oneTimePad

The optional one-time pad key.

Throws

\Exception

Validation errors.

Returns

string —

The decrypted/plain data.

xorTwoStrings()

xorTwoStrings(string  $stringOne, string  $stringTwo) : string

Calculates a XOR of two binary strings.

Parameters

string $stringOne

The first binary string.

string $stringTwo

The second binary string.

Returns

string —

The XOR output of both strings.

validateOneTimePad()

validateOneTimePad(string  $oneTimePad) 

Internal method for the validation of the one-time pad string.

Parameters

string $oneTimePad

The optional one-time pad key.

Throws

\Exception

Validation errors.