Header for the cryptography namespace.
More...
#include <stdexcept>
#include <string>
Go to the source code of this file.
|
std::tuple< std::string, std::string, std::string > | cryptography::encrypt (const std::string &plain_text, const std::string &key) |
| Encrypts the given string using AES-GCM with the given key.
|
|
std::string | cryptography::decrypt (const std::string &cipher_text, const std::string &key, const std::string &nonce, const std::string &tag) |
| Decrypts the given cipher text using AES-GCM.
|
|
|
constexpr char | cryptography::default_key [] = "rWnYJVdtxz8Iu62GSJy0OPlOat7imMb8" |
| A default encryption key used in case no key was specified.
|
|
Header for the cryptography namespace.
◆ decrypt()
std::string cryptography::decrypt |
( |
const std::string & | cipher_text, |
|
|
const std::string & | key, |
|
|
const std::string & | nonce, |
|
|
const std::string & | tag ) |
Decrypts the given cipher text using AES-GCM.
- Parameters
-
cipher_text | Text to be decrypted. |
key | Key used for decryption. |
nonce | Nonce (IV) used during enryption. |
tag | Authentication tag. |
- Returns
- The plain text.
- Exceptions
-
◆ encrypt()
std::tuple< std::string, std::string, std::string > cryptography::encrypt |
( |
const std::string & | plain_text, |
|
|
const std::string & | key ) |
Encrypts the given string using AES-GCM with the given key.
- Parameters
-
plain_text | Text to be encrapted. |
key | Key to use for encryption. |
- Returns
- The cipher text, the random nonce(IV) used, the authentication tag.
- Exceptions
-