ORE Studio 0.0.4
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
encryption Class Referencefinal

AES-256-GCM encryption service. More...

#include <encryption.hpp>

Collaboration diagram for encryption:
Collaboration graph

Static Public Member Functions

static std::string encrypt (const std::string &plaintext, const std::string &password)
 Encrypt plaintext using a password.
 
static std::string decrypt (const std::string &encrypted_data, const std::string &password)
 Decrypt ciphertext using a password.
 
static bool verify_password (const std::string &encrypted_data, const std::string &password)
 Verify if a password can decrypt the given data.
 

Static Public Attributes

static constexpr size_t SALT_LEN = 16
 
static constexpr size_t IV_LEN = 12
 
static constexpr size_t TAG_LEN = 16
 
static constexpr size_t KEY_LEN = 32
 
static constexpr int PBKDF2_ITERATIONS = 600000
 

Detailed Description

AES-256-GCM encryption service.

Provides secure encryption and decryption using AES-256-GCM with a key derived from a password using PBKDF2.

The encrypted format is: base64(salt || iv || tag || ciphertext)

Member Function Documentation

◆ encrypt()

std::string encrypt ( const std::string &  plaintext,
const std::string &  password 
)
static

Encrypt plaintext using a password.

Parameters
plaintextThe text to encrypt.
passwordThe password used to derive the encryption key.
Returns
Base64-encoded encrypted data.
Here is the caller graph for this function:

◆ decrypt()

std::string decrypt ( const std::string &  encrypted_data,
const std::string &  password 
)
static

Decrypt ciphertext using a password.

Parameters
encrypted_dataBase64-encoded encrypted data.
passwordThe password used to derive the decryption key.
Returns
Decrypted plaintext.
Exceptions
std::runtime_errorif decryption fails.
Here is the caller graph for this function:

◆ verify_password()

bool verify_password ( const std::string &  encrypted_data,
const std::string &  password 
)
static

Verify if a password can decrypt the given data.

Parameters
encrypted_dataBase64-encoded encrypted data.
passwordThe password to verify.
Returns
true if the password is correct.
Here is the caller graph for this function: