Skip to content

lin-raymond-dev/AppliedCryptographyProject2

Repository files navigation

AES Block Cipher Mode Selection Tool

This project helps users with no cryptography background select the right AES block cipher mode (ECB, CBC, OFB, CTR, GCM, SIV, XTS) by answering a short series of questions. It consists of two parts: a Python decision tree generator and a React web app.

Decision Tree Generator (decision_tree.py)

A standalone Python script that reads the implementation usage table (ImplementationUsageTable.csv) and builds a decision tree using the ID3 algorithm. The tree splits on security-relevant attributes (e.g. integrity, error propagation, parallelism) and uses weighted information gain with a cardinality penalty to produce a multi-question path rather than a flat one-shot tree.

Features:

  • Interactive mode — asks multiple-choice questions in the terminal and recommends an AES mode
  • "I don't know" support — skipping a question explores all branches and returns ranked results
  • Evaluation — runs 1000 random trials to measure accuracy vs. a random-choice baseline
  • JSON export — outputs the tree as quiz_tree.json for use by the React frontend

How to run

Make sure Python 3 is installed. No external dependencies are required.

# Interactive mode — answers questions to recommend an AES mode
python decision_tree.py

# Print the learned decision tree structure
python decision_tree.py --print-tree

# Run evaluation (1000 trials, accuracy vs random baseline)
python decision_tree.py --evaluate

# Export the tree as JSON for the React frontend
python decision_tree.py --export-json

React Web App (my-app/)

A React frontend that presents the decision tree as an interactive quiz with a visual, user-friendly interface. Users click through multiple-choice questions and receive a recommended AES mode with an explanation of why it fits their needs.

How to run

cd my-app
npm install
npm run dev

Integration

The decision tree generator and the React app are connected through the exported quiz_tree.json file. To update the quiz after changing the CSV table or tweaking the tree weights:

  1. Edit ImplementationUsageTable.csv with new rows/columns as needed
  2. Run the export:
    python decision_tree.py --export-json
  3. Copy the output into the React app:
    cp quiz_tree.json my-app/src/quiz_tree.json
  4. The React app reads this JSON to drive its quiz flow — no manual question editing needed.

This means the web app's quiz is always generated from the same ID3 algorithm and CSV data as the command-line version.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors