Limo
A simple mod manager
Loading...
Searching...
No Matches
cryptography.h File Reference

Header for the cryptography namespace. More...

#include <stdexcept>
#include <string>
Include dependency graph for cryptography.h:

Go to the source code of this file.

Classes

class  CryptographyError
 Exception indicating an error during a cryptographic operation. More...
 

Functions

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.
 

Variables

constexpr char cryptography::default_key [] = "rWnYJVdtxz8Iu62GSJy0OPlOat7imMb8"
 A default encryption key used in case no key was specified.
 

Detailed Description

Header for the cryptography namespace.

Function Documentation

◆ 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_textText to be decrypted.
keyKey used for decryption.
nonceNonce (IV) used during enryption.
tagAuthentication tag.
Returns
The plain text.
Exceptions
CryptographyErrorWhen an OpenSSL internal error occurs.

◆ 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_textText to be encrapted.
keyKey to use for encryption.
Returns
The cipher text, the random nonce(IV) used, the authentication tag.
Exceptions
CryptographyErrorWhen an OpenSSL internal error occurs.