Code Monkey home page Code Monkey logo

yetanotherasymmetriclib's Introduction

Yet Another Asymmetric Lib (YAAL)

This library provides an ultra-simplified version of the RSA encryption algorithm for educational and demonstration purposes. The RSA algorithm is a widely-used public-key cryptography system that allows secure transmission of information over unsecured channels. The encryption and decryption process is based on the use of two keys, a public key and a private key, which are mathematically related but cannot be derived from one another.

This library requires the gmpy2 and secrets modules for optimal performance, but fallback options using sympy and random are available if these modules are not available on the system.

Installation

pip install -r requirements.txt

Usage

To use this library, import the generate_keys, crypt, and decrypt functions as follows:

from yaal import generate_keys, crypt, decryption  # or `__all__`

Generating keys

To generate a pair of public and private keys, use the generate_keys function with a specified number of bits (minimum recommended is 64):

public_key, private_key = generate_keys(bits=256)

The generate_keys function returns a tuple containing the public key (e, n) and the private key (d, n).

Encryption

To encrypt a message using the public key, use the crypt function:

encrypted_data = crypt("Hello World!", public_key)

The crypt function returns a list of integers representing the encrypted message.

Decryption

To decrypt the encrypted message using the private key, use the decrypt function:

decrypted_data = decrypt(encrypted_data, private_key)

The decrypt function returns the original message as a string.

Benchmarking

To start the benchmark, just run :

python3 benchmark.py

yetanotherasymmetriclib's People

Contributors

imsumire avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.