Encapsulates the toxencrypsave API. Since key derivation is work intensive and to avoid storing plaintext passwords in memory, use a ToxEncrypt object and encrypt() or decrypt() when you have to encrypt or decrypt more than once with the same password.
More...
#include <toxencrypt.h>
Encapsulates the toxencrypsave API. Since key derivation is work intensive and to avoid storing plaintext passwords in memory, use a ToxEncrypt object and encrypt() or decrypt() when you have to encrypt or decrypt more than once with the same password.
Definition at line 29 of file toxencrypt.h.
◆ ~ToxEncrypt()
ToxEncrypt::~ToxEncrypt |
( |
| ) |
|
Frees the passKey before destruction.
Definition at line 45 of file toxencrypt.cpp.
◆ ToxEncrypt() [1/3]
ToxEncrypt::ToxEncrypt |
( |
| ) |
|
|
delete |
◆ ToxEncrypt() [2/3]
ToxEncrypt::ToxEncrypt |
( |
const ToxEncrypt & |
other | ) |
|
|
delete |
◆ ToxEncrypt() [3/3]
ToxEncrypt::ToxEncrypt |
( |
Tox_Pass_Key * |
key | ) |
|
|
explicitprivate |
Constructs a ToxEncrypt object from a Tox_Pass_Key.
- Parameters
-
key | Derived key to use for encryption and decryption. |
Definition at line 54 of file toxencrypt.cpp.
◆ decrypt()
QByteArray ToxEncrypt::decrypt |
( |
const QByteArray & |
ciphertext | ) |
const |
Decrypts data encrypted with this module, using the stored key.
- Returns
- The plaintext or an empty QByteArray on failure.
- Parameters
-
ciphertext | The encrypted data. |
Definition at line 245 of file toxencrypt.cpp.
◆ decryptPass()
QByteArray ToxEncrypt::decryptPass |
( |
const QString & |
password, |
|
|
const QByteArray & |
ciphertext |
|
) |
| |
|
static |
Decrypts data encrypted with this module.
- Returns
- The plaintext or an empty QByteArray on failure.
- Parameters
-
password | The password used to encrypt the data. |
ciphertext | The encrypted data. |
Definition at line 120 of file toxencrypt.cpp.
◆ encrypt()
QByteArray ToxEncrypt::encrypt |
( |
const QByteArray & |
plaintext | ) |
const |
Encrypts the plaintext with the stored key.
- Returns
- Encrypted data or empty QByteArray on failure.
- Parameters
-
plaintext | The data to encrypt. |
Definition at line 218 of file toxencrypt.cpp.
◆ encryptPass()
QByteArray ToxEncrypt::encryptPass |
( |
const QString & |
password, |
|
|
const QByteArray & |
plaintext |
|
) |
| |
|
static |
Encrypts the plaintext with the given password.
- Returns
- Encrypted data or empty QByteArray on failure.
- Parameters
-
password | Password to encrypt the data. |
plaintext | The data to encrypt. |
Definition at line 90 of file toxencrypt.cpp.
◆ getMinBytes()
int ToxEncrypt::getMinBytes |
( |
| ) |
|
|
static |
Gets the minimum number of bytes needed for isEncrypted()
- Returns
- Minimum number of bytes needed to check if data was encrypted using this module.
Definition at line 64 of file toxencrypt.cpp.
◆ isEncrypted()
bool ToxEncrypt::isEncrypted |
( |
const QByteArray & |
ciphertext | ) |
|
|
static |
Checks if the data was encrypted by this module.
- Parameters
-
ciphertext | The data to check. |
- Returns
- True if the data was encrypted using this module, false otherwise.
Definition at line 74 of file toxencrypt.cpp.
◆ makeToxEncrypt() [1/2]
std::unique_ptr< ToxEncrypt > ToxEncrypt::makeToxEncrypt |
( |
const QString & |
password | ) |
|
|
static |
Factory method for the ToxEncrypt object.
- Parameters
-
password | Password to use for encryption. |
- Returns
- A std::unique_ptr containing a ToxEncrypt object on success, or an or an empty std::unique_ptr on failure.
Derives a key from the password and a new random salt.
Definition at line 156 of file toxencrypt.cpp.
◆ makeToxEncrypt() [2/2]
std::unique_ptr< ToxEncrypt > ToxEncrypt::makeToxEncrypt |
( |
const QString & |
password, |
|
|
const QByteArray & |
toxSave |
|
) |
| |
|
static |
Factory method for the ToxEncrypt object.
- Parameters
-
password | Password to use for encryption. |
toxSave | The data to read the salt for decryption from. |
- Returns
- A std::unique_ptr containing a ToxEncrypt object on success, or an or an empty std::unique_ptr on failure.
Derives a key from the password and the salt read from toxSave.
Definition at line 182 of file toxencrypt.cpp.
◆ operator=()
◆ passKey
Tox_Pass_Key* ToxEncrypt::passKey = nullptr |
|
private |
The documentation for this class was generated from the following files: