| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Modern C++17 implementation of AES-128 with CBC mode, PKCS#7 padding, and a practical command-line interface. The project keeps the cryptographic core, padding logic, CBC chaining, and tooling separated so that each piece is easy to study, test, and reuse.
BlockCrypt/ ├── CMakeLists.txt # Root CMake project (enables AddressSanitizer by default) ├── include/ # Public headers shared by the library & CLI │ ├── CBC.hpp │ ├── blockcrypt.hpp │ └── padding.hpp ├── src/ # AES core, CBC mode, padding implementations │ ├── CBC.cpp │ ├── blockcrypt.cpp │ └── padding.cpp ├── constants/ # S-Boxes, inverse S-Boxes, Rcon values │ ├── BlockCryptConstants.cpp │ └── BlockCryptConstants.hpp ├── tests/ # Catch2 tests & benchmarks (registered with CTest) │ ├── CMakeLists.txt │ ├── benchmark_performance.cpp │ └── test_blockcrypt.cpp ├── third_party/ # Vendored Catch2 headers (used when FetchContent is skipped) ├── main.cpp # Command-line entry point ├── README.md # You are here ├── LICENSE └── build/ # (generated) CMake build tree
ℹ️ The root CMakeLists.txt enables AddressSanitizer (-fsanitize=address) and debug symbols by default. To change this, pass your own compiler flags or configure a Release build (-DCMAKE_BUILD_TYPE=Release).
cmake -S . -B build
cmake --build buildcd build
# Full suite (includes long-running benchmarks ~12 minutes total)
ctest --output-on-failure --timeout 1200
# Skip benchmarks to keep CI fast
ctest -LE benchmark --output-on-failurecd build
ctest -L benchmark --output-on-failure --timeout 600The blockcrypt executable reads/writes binary data either from files or via standard streams. Keys and IVs must be provided as hexadecimal strings (32 hex characters → 16 bytes). Defaults:
# Quick help
./build/blockcrypt --help
# Encrypt file → ciphertext.bin
./build/blockcrypt encrypt \
-k 2b7e151628aed2a6abf7158809cf4f3c \
-i 000102030405060708090a0b0c0d0e0f \
-I plaintext.bin \
-O ciphertext.bin
# Decrypt file → decrypted.bin
./build/blockcrypt decrypt \
-k 2b7e151628aed2a6abf7158809cf4f3c \
-i 000102030405060708090a0b0c0d0e0f \
-I ciphertext.bin \
-O decrypted.bin
# Stream-based usage (stdin/stdout when -I / -O omitted)
cat message.txt | ./build/blockcrypt encrypt -k ... -i ... > encrypted.binErrors such as malformed hex strings, missing files, or padding inconsistencies are reported to stderr with non-zero exit codes.
#include "blockcrypt.hpp"
#include "CBC.hpp"
#include "padding.hpp"
int main()
{
BlockCrypt::Key key{
0x2B, 0x7E, 0x15, 0x16,
0x28, 0xAE, 0xD2, 0xA6,
0xAB, 0xF7, 0x15, 0x88,
0x09, 0xCF, 0x4F, 0x3C};
BlockCrypt::Block iv{
0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B,
0x0C, 0x0D, 0x0E, 0x0F};
std::vector<uint8_t> data{'H', 'e', 'l', 'l', 'o'};
BC::encryptCBC(data, key, iv); // ciphertext w/ PKCS#7 padding
BC::decryptCBC(data, key, iv); // returns to original plaintext
std::cout << std::string(data.begin(), data.end()) << '\n';
}tests/test_blockcrypt.cpp exercises the cryptographic primitives and padding helpers:
tests/benchmark_performance.cpp registers Catch2 benchmarks used to profile ECB/CBC latency and throughput. Benchmarks are labeled with benchmark to keep them opt-in for quick test runs.
This project is licensed under the MIT License. See LICENSE for details.
Questions, feedback, ideas?
| Back | FazBrowse Home | New Git URL |