Photon Fusion 2.1.1

DataEncryptor Class Reference

Responsible for encrypting and decrypting data buffers. More...

Inherits IDataEncryption.

Public Member Functions

bool ComputeHash (byte *buffer, ref int bufferLength, int capacity)
 Compute the Buffer hash and append it to the buffer itself.
Parameters
bufferData to compute the hash
bufferLengthLength of the data to hash
capacityBuffer total capacity
Returns
True if the hash was properly computed, false otherwise

bool DecryptData (byte *buffer, ref int bufferLength, int capacity)
 Decrypt data in place and update it's length.
Parameters
bufferData to decrypt
bufferLengthLength of the data to decrypt
capacityBuffer total capacity
Returns
True if the decryption was completed, false otherwise

void Dispose ()
 Dispose of the DataEncryptor.
bool EncryptData (byte *buffer, ref int bufferLength, int capacity)
 Encrypts the data in the provided buffer.
byte[] GenerateKey ()
 Generate the key used used by the encryption implementation.
Returns
Key used to setup the encryption implementation

void Setup (byte[] key)
 Setup the encryption implementation with the right key.
bool ValidateKey (byte[] key)
 Check if the given key is valid.
Returns
True if fulfills all requirements for a valida key

bool VerifyHash (byte *buffer, ref int bufferLength, int capacity)
 Verify the buffer hash that was appended to the buffer.
Parameters
bufferBuffer to check the hash
bufferLengthLength of the data to hash
capacityBuffer total capacity
Returns
True if the hash was properly verified, false otherwise

Detailed Description

Responsible for encrypting and decrypting data buffers.

Member Function Documentation

◆ EncryptData()

bool EncryptData ( byte * buffer,
ref int bufferLength,
int capacity )

Encrypts the data in the provided buffer.

Parameters
bufferThe buffer containing the data to be encrypted.
bufferLengthThe length of the data in the buffer.
capacityThe total capacity of the buffer.
Returns
Returns true if the encryption was successful, false otherwise.
Exceptions
InvalidOperationExceptionThrown when the encryption provider is not initialized.
ArgumentExceptionThrown when the original buffer cannot hold the encrypted data.

Implements IDataEncryption.