Cryptographic utilities for common encryption algorithms.
- Multiple encryption algorithms support
- Symmetric encryption/decryption
- Key-based security
- Exception handling for invalid operations
- Simple API for common cryptographic needs
Caesar: Classic shift cipher (3 positions)Vigenere: Poly-alphabetic substitution cipherXOR: Bitwise XOR cipherSubstitution: Alphabet reversal cipherTransposition: Columnar transposition cipher
Encryption(Alg algorithm_a, const std::string& key_a = "")- Constructor with algorithm selection and optional keystd::string Encrypt(const std::string& plain_text_a)- Encrypts plaintextstd::string Decrypt(const std::string& cipher_text_a)- Decrypts ciphertext
#include <CUtils/Encryption.hpp>
int main()
{
// Vigenere cipher with key
CUtils::Encryption vigenere_(CUtils::Alg::Vigenere, "secret");
std::string encrypted_ = vigenere.Encrypt("HelloWorld");
std::string decrypted_ = vigenere.Decrypt(encrypted);
// XOR cipher with key
CUtils::Encryption xor_cipher_(CUtils::Alg::XOR, "\x1f");
std::string xor_enc_ = xor_cipher_.Encrypt("SensitiveData");
// Caesar cipher (no key required)
CUtils::Encryption caesar_(CUtils::Alg::Caesar);
std::string caesar_msg_ = caesar_.Encrypt("ABCxyz");
return 0;
}Криптографические утилиты для распространенных алгоритмов шифрования.
- Поддержка нескольких алгоритмов шифрования
- Симметричное шифрование/дешифрование
- Ключевая безопасность
- Обработка ошибок для недопустимых операций
- Простой API для базовых криптографических задач
Caesar: Классический шифр сдвига (3 позиции)Vigenere: Полиалфавитный подстановочный шифрXOR: Побитовый XOR-шифрSubstitution: Шифр с обратным алфавитомTransposition: Столбцовый метод перестановки
-
Encryption(Alg algorithm_a, const std::string& key_a = "")- Конструктор с выбором алгоритма и опциональным ключом -
std::string Encrypt(const std::string& plain_text_a)- Шифрование открытого текста -
std::string Decrypt(const std::string& cipher_text_a)- Дешифрование зашифрованного текста
#include <CUtils/Encryption.hpp>
int main()
{
// Шифр Виженера с ключом
CUtils::Encryption vigenere_(CUtils::Alg::Vigenere, "secret");
std::string encrypted_ = vigenere.Encrypt("HelloWorld");
std::string decrypted_ = vigenere.Decrypt(encrypted);
// Исключающий шифр с ключом
CUtils::Encryption xor_cipher_(CUtils::Alg::XOR, "\x1f");
std::string xor_enc_ = xor_cipher_.Encrypt("SensitiveData");
// Шифр Цезаря (ключ не требуется)
CUtils::Encryption caesar_(CUtils::Alg::Caesar);
std::string caesar_msg_ = caesar_.Encrypt("ABCxyz");
return 0;
}