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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file fast-encrypt-1.0.0.tar.gz.

File metadata

  • Download URL: fast-encrypt-1.0.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for fast-encrypt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1e7473d075758643ff53b5b459b791fd4c5ef91dcc6b76d8a4998366404ceb67
MD5 f252d95ad2ad1c4d4e4cf920470b45fd
BLAKE2b-256 67b273506ce097e6c13ef59b42cca3029adeef245a29389279ad3cbdb90fc5c8

See more details on using hashes here.

File details

Details for the file fast_encrypt-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fast_encrypt-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for fast_encrypt-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 912cb3af82c6b4e424ea44d7adee42ce42efede64601ce73be740ccf03dd23fb
MD5 06ff08ecc0bea051df04a4f81bb720a0
BLAKE2b-256 7cddea65e9fcc62583645c640438515f9d1bb871d0dd48b9a020390e2a8d9723

See more details on using hashes here.

Supported by

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