Skip to main content

fast-encrypt is a comprehensive Python library that offers a variety of cryptographic methods to protect sensitive data simply and effectively.

Project description


fast-encrypt

fast-encrypt is a comprehensive Python library that offers a variety of cryptographic methods to protect sensitive data simply and effectively.

Table of contents

Installation

Using pip:

pip install fast-encrypt

Docs

See our Docs for comprehensive and detailed documentation on fast-encrypt. In the documentation, you will find in-depth explanations, usage examples, and additional resources to help you maximize your experience with fast-encrypt.

This package offers classes for:

Examples

Caesar's cipher

To encrypt some text using Caesar's cipher, fist of all, you need import and instantiate the CaesarsCipher class providing the shift for chars.

from fast_encrypt import CaesarsCipher


encryptor = CaesarsCipher(1) # shift = 1

Then, you'll be able to encrypt a text.

plaintext = 'Hello World!'

encrypted_text = encryptor.encrypt(plaintext)

print(encrypted_text)

The encrypted_text will be:

Ifmmp Xpsme!

To decrypt it's very simple.

decrypted_text = encryptor.decrypt(encrypted_text)

print(decrypted_text)

The decrypted_text will be:

Hello World!

Morse code

To encrypt some text using Morse code, fist of all, you need import and instantiate the MorseCode class.

from fast_encrypt import MorseCode


encryptor = MorseCode()

Then, you'll be able to encrypt a text.

plaintext = 'Hello World!'

encrypted_text = encryptor.encrypt(plaintext)

print(encrypted_text)

The encrypted_text will be:

.... . .-.. .-.. --- .-- --- .-. .-.. -..

To decrypt it's very simple.

decrypted_text = encryptor.decrypt(encrypted_text)

print(decrypted_text)

The decrypted_text will be:

HELLOWORLD

Substitution cipher

To encrypt some text using substitution cipher, fist of all, you need import and instantiate the Substitution class providing the alphabet for substitution.

from fast_encrypt import Substitution


encryptor = Substitution('poiuytrewqlkjhgfdsamnbvcxz') # the alphabet for substitution

Then, you'll be able to encrypt a text.

plaintext = 'Hello World!'

encrypted_text = encryptor.encrypt(plaintext)

print(encrypted_text)

The encrypted_text will be:

Eykkg Vgsku!

To decrypt it's very simple.

decrypted_text = encryptor.decrypt(encrypted_text)

print(decrypted_text)

The decrypted_text will be:

Hello World!

Pipeline

You can create a pipeline of simple encryptors, fist of all, you need import and instantiate the Pipeline class providing the list of simple encryptors.

from fast_encrypt import (
    Pipeline,
    CaesarsCipher,
    Substitution,
    MorseCode
)


pipeline = Pipeline([
    CaesarsCipher(3),
    Substitution('mnbvcxzlkjhgfdsapoiuytrewq'),
    MorseCode()
])

Then, you'll be able to encrypt a text.

plaintext = 'Hello World!'

encrypted_text = pipeline.encrypt(plaintext)

print(encrypted_text)

The encrypted_text will be:

.... .-.. ... ... --- --.- --- -.-- ... --..

To decrypt it's very simple.

decrypted_text = pipeline.decrypt(encrypted_text)

print(decrypted_text)

The decrypted_text will be:

HELLOWORLD

RSA

For a more complex and secure way to encrypt your data, you can use our RSA class for the RSA cryptosystem.

To encrypt some text using , fist of all, you need import and instantiate the RSA class providing the key length in bits (default = 1024).

from fast_encrypt import RSA


encryptor = RSA() # default key length = 1024

Then, you must generate the public and private key (public key is used for encrypt a text, private is used for decrypt)

public_key, private_key = encryptor.generate_keypair()

Then, you'll be able to encrypt a text.

plaintext = 'Hello World!'

encrypted_text = encryptor.encrypt(public_key, plaintext)

print(encrypted_text)

The encrypted_text will can be:

1485228768820288706400698504222851526198153333611564433069219712708655679297610713312684847266463375809614570944...

The three dots means the result own more numbers.

To decrypt it's very simple.

decrypted_text = encryptor.decrypt(private_key, encrypted_text)

print(decrypted_text)

The decrypted_text will be:

Hello World!

Contributing

You may contribute in several ways like creating new features, fixing bugs, improving documentation and examples or translating any document here to your language. Find more information in CONTRIBUTING.md.

License

MIT - Alberto Frigatto, 2024

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast-encrypt-1.0.0.tar.gz (18.3 kB view hashes)

Uploaded Source

Built Distribution

fast_encrypt-1.0.0-py3-none-any.whl (18.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page