This is an implementation and usage example of a dictionary in C.
It supports:
- Hashing
- Collisions (keys must be different)
- String-like keys
- Some utility functions as shown in
src/main.c
This works both on Windows, Linux and MacOS
- Git for cloning the repo. Choose the correct installation for your OS.
- Windows
- Visual Studio: Install Visual Studio with
Desktop development with C++
selected - GCC for windows (if don't have one already)
- Download and unzip the correct file for your platform (probably
msvcrt-x86_64
) - Add the
bin
directory in the unzipped folder to thePATH
environment variable. Here is a tutorial on how to add items toPATH
- Download and unzip the correct file for your platform (probably
- Python 3.10.5: Any Python version above
3.8
works but make sure you check the boxadd to path
on the last screen of the installation
- Visual Studio: Install Visual Studio with
- Linux (update the installation for your distro if different):
Build essentials
(should be installed by default) andpython3
dependenciesapt update; apt install build-essential python3 python3-venv -y
Every time you see a code block, you should run it in a:
Terminal
: if you are on Linux / MacOSDeveloper: PowerShell for VS
: if you're on Windows (this is installed with Visual Studio, search for it)
-
git clone https://github.com/darkarp/c-dictionary cd c-dictionary
-
Create python virtual environment and activate it
- Windows:
py -m venv venv .\venv\Scripts\activate
- Linux / MacOS:
python3 -m venv venv source venv/bin/activate
- Windows:
-
Generate Makefile
python makefile_gen.py
-
Running the makefile
- Windows
- If cleanup is required:
nmake clean
- Then run this:
nmake all
- If cleanup is required:
- Linux / MacOS
- If cleanup is required:
make clean
- Then run this:
make all
- For a comprehensive help screen:
make help
- If cleanup is required:
- Windows
-
Running the example
main.exe
- Windows:
.\bin\main.exe
- Linux / MacOS:
./bin/main
- Windows:
This project comes with a python statistics script, located in: statistics/collisions.py
. This is an educational script which computes the ratio of collisions for this dictionary for a particular predefined size of the dict.
It makes use of a C library for python. If you wish to run the statistics/collisions.py
, the procedure is as follows:
python statistics/setup.py install
python statistics/collisions.py
- Better documentation
- Utility functions
- Better stability check
- Multiple hash support
- File & membuffer I/O for saving/loading (pickle)
- Testing
For access to a community full of aspiring computer security experts, ranging from the complete beginner to the seasoned veteran, join our:
- Discord Server: WhiteHat Hacking discord
- Website: Whitehat Hacking Website
If you wish to contact me, you can do so via: mario@whitehathacking.tech