Skip to content

Latest commit

 

History

History
136 lines (123 loc) · 5.24 KB

README.md

File metadata and controls

136 lines (123 loc) · 5.24 KB

Simple dictionary in C

GitHub issues

Twitch Status
Twitch Status

Table of Contents


About the project

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


Getting started

Requirements

  • 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 the PATH environment variable. Here is a tutorial on how to add items to PATH
    • Python 3.10.5: Any Python version above 3.8 works but make sure you check the box add to path on the last screen of the installation
  • Linux (update the installation for your distro if different):
    • Build essentials (should be installed by default) and python3 dependencies
      apt update; apt install build-essential python3 python3-venv -y

Usage

Every time you see a code block, you should run it in a:

  • Terminal: if you are on Linux / MacOS
  • Developer: PowerShell for VS: if you're on Windows (this is installed with Visual Studio, search for it)
  1. Clone the repo and go into it:

    git clone https://github.com/darkarp/c-dictionary
    cd c-dictionary
    
  2. 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
  3. Generate Makefile

    python makefile_gen.py
  4. Running the makefile

    • Windows
      • If cleanup is required: nmake clean
      • Then run this: nmake all
    • Linux / MacOS
      • If cleanup is required: make clean
      • Then run this: make all
      • For a comprehensive help screen: make help
  5. Running the example main.exe

    • Windows: .\bin\main.exe
    • Linux / MacOS: ./bin/main

Statistics Module (optional)

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:

1. Install the C module:

python statistics/setup.py install

2. Run statistics/collisions.py

python statistics/collisions.py

TODO

  • Better documentation
  • Utility functions
  • Better stability check
  • Multiple hash support
  • File & membuffer I/O for saving/loading (pickle)
  • Testing

Learn More

For access to a community full of aspiring computer security experts, ranging from the complete beginner to the seasoned veteran, join our:

If you wish to contact me, you can do so via: [email protected]


License

AGPL-3.0