This project explores four main areas: strings, system calls, caesar cipher, and substitution cipher. It provides both a C library and unit tests, making it a practical codebase designed for Linux environments. For more background on Linux environments and code I/O, see: Linux Operating Systems - rsiddiq.com.
- String helpers (
get_str_length,copy_str, case conversion, find-first/last index) PersonandGroupstructs with basic operations- Caesar cipher (encrypt/decrypt)
- General substitution cipher (encrypt/decrypt, key validation + inversion)
- Unit tests with Criterion
StringsAndCiphers/
├─ .gitignore
├─ Makefile
├─ README.md
├─ unit_tests.c
├─ build/
│ └─ tests_runner
├─ src/
│ ├─ StringsAndCiphers.c
│ ├─ StringsAndCiphers.h
│ ├─ StringsAndCiphers.o
│ └─ log.h
├─ tests/
│ ├─ unittests_caesar.c
│ ├─ unittests_string.c
│ ├─ unittests_struct.c
│ └─ unittests_substitution.c
└─ .vscode/
├─ launch.json
└─ tasks.json
This project is intended for Linux systems and requires make, a C11 compiler, and Criterion.
sudo apt-get install build-essential pkg-config make
# Criterion (Ubuntu 22.04+ has libcriterion-dev, else build from source)
sudo apt-get install libcriterion-dev-
Windows: Use WSL (Windows Subsystem for Linux) to run a Linux environment with
makeand a C compiler. -
macOS: Install Xcode command line tools (
xcode-select --install) and Criterion via Homebrew (brew install criterion). -
Docker: Build and test inside a Linux-based container for a consistent environment:
docker run --rm -it -v $(pwd):/app -w /app gcc:latest bash apt-get update && apt-get install -y build-essential pkg-config libcriterion-dev make && ./build/tests_runner
make
./build/tests_runnermake cleanStringsAndCiphers.c/.h can be dropped into another project, or you can build a static/shared library if desired. Key entry points include:
get_str_length,copy_str,to_uppercase,to_lowercaseperson_make_new,person_to_string,group_make_new,add_person,remove_personencrypt_caesar,decrypt_caesaris_reversible,get_decryption_key,encrypt_substitution,decrypt_substitution
-
Compiles with
-Wall -Wextra -Wpedantic -std=c11. Treat warnings as errors locally with:CFLAGS="-Wall -Wextra -Wpedantic -Werror -std=c11" make -
Memory safety: APIs that return newly allocated strings specify that the caller owns the memory.
-
Tests: Criterion-based tests live under
tests/and run via thebuild/tests_runnertarget.
This repo includes .vscode/launch.json and .vscode/tasks.json to make building and running tests convenient for VS Code users. For JetBrains CLion users, the project also works smoothly: open the folder as a CMake project, set up Criterion as an external library (via pkg-config or manual linking), and configure the test target to run build/tests_runner.