# DataBlockEncryptor Class Reference

Encrypts and decrypts data blocks. More...

`#include <DataBlockEncryptor.h>`

List of all members.

## Public Member Functions

| DataBlockEncryptor ()
| Constructor.
| ~DataBlockEncryptor ()
| Destructor.
bool | IsKeySet (void) const
void | SetKey (const unsigned char key[16])
void | UnsetKey (void)
| Unset the encryption key.
void | Encrypt (unsigned char *input, unsigned int inputLength, unsigned char *output, unsigned int *outputLength, RakNetRandom *rnr)
bool | Decrypt (unsigned char *input, unsigned int inputLength, unsigned char *output, unsigned int *outputLength)

## Detailed Description

Encrypts and decrypts data blocks.

## Member Function Documentation

bool DataBlockEncryptor::Decrypt | ( | unsigned char * | input,
|  | unsigned int | inputLength,
|  | unsigned char * | output,
|  | unsigned int * | outputLength |
| ) |  |  |

Decryption removes bytes, as few as 6. Output should be large enough to hold this. Output can be the same memory block as input

Parameters:

  `[in]` | input | the input buffer to decrypt
  `[in]` | inputLength | the size of the input buffer
  `[in]` | output | the output buffer to store decrypted data
  `[in]` | outputLength | the size of the output buffer

Returns:
  False on bad checksum or input, true on success

void DataBlockEncryptor::Encrypt | ( | unsigned char * | input,
|  | unsigned int | inputLength,
|  | unsigned char * | output,
|  | unsigned int * | outputLength,
|  | RakNetRandom * | rnr |
| ) |  |  |

Encryption adds 6 data bytes and then pads the number of bytes to be a multiple of 16. Output should be large enough to hold this. Output can be the same memory block as input

Parameters:

  `[in]` | input | the input buffer to encrypt
  `[in]` | inputLength | the size of the input buffer
  `[in]` | output | the output buffer to store encrypted data
  `[in]` | outputLength | the size of the output buffer

bool DataBlockEncryptor::IsKeySet | ( | void |  | ) | const

Returns:
  true if SetKey has been called previously

void DataBlockEncryptor::SetKey | ( | const unsigned char | key[16] | ) |

Set the encryption key

Parameters:

  `[in]` | key | The new encryption key

The documentation for this class was generated from the following files:

- C:/RakNet/Source/DataBlockEncryptor.h
- C:/RakNet/Source/DataBlockEncryptor.cpp