Skip to main content


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

Metadata

Release files for fast-encrypt 1.0.0

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

Source distribution (sdist)

Source distribution for fast-encrypt 1.0.0
File Size Uploaded
fast-encrypt-1.0.0.tar.gz 18.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-encrypt 1.0.0
File Interpreter ABI Platform
fast_encrypt-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / fast-encrypt-1.0.0.tar.gz

Download URL fast-encrypt-1.0.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1e7473d075758643ff53b5b459b791fd4c5ef91dcc6b76d8a4998366404ceb67
BLAKE2b-256 checksum
How to use checksums
67b273506ce097e6c13ef59b42cca3029adeef245a29389279ad3cbdb90fc5c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release files / fast_encrypt-1.0.0-py3-none-any.whl

Download URL fast_encrypt-1.0.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
912cb3af82c6b4e424ea44d7adee42ce42efede64601ce73be740ccf03dd23fb
BLAKE2b-256 checksum
How to use checksums
7cddea65e9fcc62583645c640438515f9d1bb871d0dd48b9a020390e2a8d9723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.2

2 release files

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