Conscience Core
Classes | Functions | Variables
conscience_utils::crypto Namespace Reference

Classes

class  CryptoException
 

Functions

vector< unsigned char > * encryptAES256CBC (const unsigned char *bytes, int bytesCount, const string &key, const string &iv)
 
vector< unsigned char > * encryptAES256CBC (const string &plainText, const string &key, const string &iv)
 
string decryptAES256CBC (const vector< unsigned char > &encryptedChars, string key, string iv)
 
void generateAES256KeyAndIVFromPassword (const string &password, string &key, string &iv)
 
vector< unsigned char > * encryptAES256CBCWithPassword (const string &plainText, const string &password)
 
string decryptAES256CBCWithPassword (const vector< unsigned char > &encryptedChars, const string &password)
 
static bool isBase64Char (const unsigned char c)
 
string encodeBase64 (const unsigned char *buf, unsigned int bufLen)
 
vector< unsigned char > * decodeBase64 (const string &encodedString)
 
string hashFileMd5 (const fs::path &filePath)
 
string hashMd5 (const string &input)
 
string hashSha512 (const string &input)
 
string hashUniqueSimpleShift (const string &input)
 "Perfect" hash function by shifting each character by 1000. More...
 

Variables

constexpr int AES_256_KEY_BYTES_LEN = 256 / 8
 
constexpr int AES_256_IV_BYTES_LEN = 128 / 8
 
static const std::string base64Chars
 

Function Documentation

◆ decodeBase64()

vector< unsigned char > * conscience_utils::crypto::decodeBase64 ( const string &  encodedString)

◆ decryptAES256CBC()

string conscience_utils::crypto::decryptAES256CBC ( const vector< unsigned char > &  encryptedChars,
string  key,
string  iv 
)

◆ decryptAES256CBCWithPassword()

string conscience_utils::crypto::decryptAES256CBCWithPassword ( const vector< unsigned char > &  encryptedChars,
const string &  password 
)

◆ encodeBase64()

string conscience_utils::crypto::encodeBase64 ( const unsigned char *  buffer,
unsigned int  bufferLen 
)
Parameters
buffernot deleted in this method

◆ encryptAES256CBC() [1/2]

vector< unsigned char > * conscience_utils::crypto::encryptAES256CBC ( const string &  plainText,
const string &  key,
const string &  iv 
)

◆ encryptAES256CBC() [2/2]

vector< unsigned char > * conscience_utils::crypto::encryptAES256CBC ( const unsigned char *  bytes,
int  bytesCount,
const string &  key,
const string &  iv 
)
Parameters
bytesnot deleted inside this method

◆ encryptAES256CBCWithPassword()

vector< unsigned char > * conscience_utils::crypto::encryptAES256CBCWithPassword ( const string &  plainText,
const string &  password 
)

Given password will be hashed using SHA512 to generate AES key on side and IV on another. Note : IV will be picked from generated sha512 at random indexes based on password length

◆ generateAES256KeyAndIVFromPassword()

void conscience_utils::crypto::generateAES256KeyAndIVFromPassword ( const string &  password,
string &  key,
string &  iv 
)

◆ hashFileMd5()

string conscience_utils::crypto::hashFileMd5 ( const fs::path &  filePath)

◆ hashMd5()

string conscience_utils::crypto::hashMd5 ( const string &  input)

◆ hashSha512()

string conscience_utils::crypto::hashSha512 ( const string &  input)

◆ hashUniqueSimpleShift()

string conscience_utils::crypto::hashUniqueSimpleShift ( const string &  input)

"Perfect" hash function by shifting each character by 1000.

This method takes each character of the input, adds 1000 to its ASCII code, and returns the result as a single string. It's called "perfect" because, by design, it produces a unique transformation for any input without collisions.

However, this type of hashing is of limited interest: the output remains roughly as long as the input string, and this approach primarily serves to obfuscate or blur the original data rather than providing the kind of compact digest typically expected from a hash function.

◆ isBase64Char()

static bool conscience_utils::crypto::isBase64Char ( const unsigned char  c)
inlinestatic

Variable Documentation

◆ AES_256_IV_BYTES_LEN

constexpr int conscience_utils::crypto::AES_256_IV_BYTES_LEN = 128 / 8
constexpr

◆ AES_256_KEY_BYTES_LEN

constexpr int conscience_utils::crypto::AES_256_KEY_BYTES_LEN = 256 / 8
constexpr

◆ base64Chars

const std::string conscience_utils::crypto::base64Chars
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"