Skip to main content

BlockIt

BlockIt is a Python package that provides various encryption algorithms and a CLI application for easy encryption and decryption of text. It implements the ShiftEncryption, ReverseEncryption, and MatrixEncryption algorithms and allows dynamic selection of encryption algorithms using Abstract Factory design pattern.

Deliverables

  • Implemented the following encryption algorithms: ShiftEncryption, ReverseEncryption, MatrixEncryption
  • Add the --shift option to specify the number of shifts to be performed instead of being fixed at 3
  • Dockerized the project, enabling easy testing of the application in a containerized environment using docker-compose
  • Utilized the Abstract Factory Design Pattern, enabling dynamic creation of encryption algorithms
  • Developed a CLI application using Typer, facilitating easy text encryption and decryption
  • Distributed and published the package on PyPI at https://pypi.org/project/blockit/
  • Reimplemented the Reverse Encryption Algorithm and deployed it on Vercel as a FastAPI application. This was necessary due to the previously provided endpoints experiencing timeouts and functionality issues.
  • Published a Postman collection for the API endpoints, available at https://documenter.getpostman.com/view/8975155/2s93zB528T
  • Utilized semantic commit messages to effectively track the project's progress
  • Wrote comprehensive unit tests for all encryption algorithms: ShiftEncryption, ReverseEncryption, MatrixEncryption
  • Utilized pytest and pytest-cov to run tests and generate coverage reports
  • Incorporated pre-commit hooks to ensure consistent formatting, type checking, and linting before each commit
  • Automated formatting and versioning of the package using a Makefile
  • Documentation including installation instructions, usage guidelines, known issues, testing instructions, and research details.
  • A well-documented codebase, providing clear documentation for each function and class

Installation

Inside a Docker Container

  1. Run docker-compose up --build to build the image and run the container
  2. Run docker-compose exec web bash to enter the container
  3. The blockit CLI is now available inside the container

Published CLI

  1. Install the package using pip install blockit
  2. Run blockit --help to see the available commands and options
                                                                                                                                                                                                 
 Usage: blockit [OPTIONS] TEXT ALGORITHM METHOD                                                                                                                                                  
                                                                                                                                                                                                 
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    text           TEXT  Text to be encrypted/decrypted [default: None] [required]                                                                                                           │
│ *    algorithm      TEXT  Encryption algorithm to be used [default: None] [required]                                                                                                          │
│ *    method         TEXT  Method to be used: 'Encrypt' or 'Decrypt' [default: None] [required]                                                                                                │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Manually

  1. Clone the repository, git clone https://github.com/0xsirsaif/blockit, and cd into it
  2. Create a virtual environment, python -m venv venv, and activate it, source venv/bin/activate
  3. Install the dependencies, pip install -r requirements.txt
  4. Run python -m blockit --help to see the available commands and options

Usage

ShiftEncryption

  • default shift value is 3, but can be changed using the --shift option
$ blockit "Hello World" shift Encrypt
Khoor Zruog
$ blockit "Khoor Zruog" shift Decrypt
Hello World

ReverseEncryption

$ blockit "Hello World" reverse Encrypt
dlroW olleH
$ blockit "dlroW olleH" reverse Decrypt
Hello World

MatrixEncryption

$ blockit "Hello World" matrix Encrypt
$ blockit "Hello World" matrix Decrypt

Testing

Tests are grouped into three Test Classes: TestShiftEncryption, TestReverseEncryption, and TestMatrixEncryption.

  • To run all tests, run the following command:
$ python -m pytest --cov tests/ -vvs
  • To run a specific test with keyword, run the following command:
$ python -m pytest --cov tests/ -vvs -k <keyword>

Known Issues

Please be aware that there is currently a bug in the MatrixEncryption algorithm. I have been unable to fix it in time for the deadline, but I will continue working on it and will push the fix as soon as possible. I've added a test case for the bug as well.

License

MIT License

Metadata

Release files for blockit 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blockit 0.0.5
File Size Uploaded Provenance Actions
blockit-0.0.5.tar.gz 169.1 kB Without provenance Details for blockit-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for blockit 0.0.5
File Interpreter ABI Platform Actions
blockit-0.0.5-py3-none-any.whl Python 3 none any Details for blockit-0.0.5-py3-none-any.whl

Total release size: 180.5 kB

Release files / blockit-0.0.5.tar.gz

Download URL blockit-0.0.5.tar.gz
Size 169.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0a16933b4c97627716951b84048b213473dc168bd7716ca2a533d425d79aa3f1
BLAKE2b-256 checksum
How to use checksums
065e407063599f346eddbf7b28c247bbd2844c377836222b49b82745328df6b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / blockit-0.0.5-py3-none-any.whl

Download URL blockit-0.0.5-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4d3f84b7d40c7633c8146ff78588c66dd83ab98e97f8cf6684a104365a681d8
BLAKE2b-256 checksum
How to use checksums
c73236688d8cb147833344a416c891ccfb80d1fc815d25784edd379817eaf056
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Security for blockit 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page