Skip to content

Latest commit

 

History

History
97 lines (60 loc) · 2.28 KB

README.md

File metadata and controls

97 lines (60 loc) · 2.28 KB

Cryptography Algorithms Project

About

This toy project serves as a practical tool for understanding the inner workings of various cryptography algorithms through hands-on implementation.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Python installed on your system.

Installation

Clone the repository to your local machine.

git clone https://github.com/Elias-Yona/cryptography
cd cryptography

Ensure that Poetry is installed on your system. If not, you can install it by executing the following command in your terminal.

curl -sSL https://install.python-poetry.org | python3 -

Use Poetry to build the project.

poetry build

After building the project, you can install it locally using Poetry with the following command.

poetry install

Alternatively, if you prefer using pip, you can install the project directly from the distribution files generated by the poetry build command.

pip install .

Usage

To use the implemented algorithms, follow the instructions below.

SHA-1 Hashing

To hash a message using the SHA-1 algorithm, execute the following command in your terminal:

sha1 "your message here"

Replace "your message here" with the actual text you wish to hash.

HMAC Generation

To generate an HMAC for a message using a specified hash function, use the following command:

python main.py <key> <message> <digest>

Replace the placeholders as follows:

  • <key>: The secret key used for the HMAC computation.
  • <message>: The input message for which the HMAC will be computed.
  • <digest>: The name of the hash function (e.g., sha256, sha1, md5).

Example:

python main.py YourSecretKey1234567890 "This is a test message" sha256

Expected output:

HMAC (hex): 1ca0369c1bc124d3889dfec78924c2fa329c34c708559057eee59040f878c1f6

Running Tests

The project includes unit tests to verify the correctness of the implemented algorithms. To run these tests, use the following command:

python -m unittest discover -s tests

This command will automatically discover and run all test cases located within the tests directory.