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:

- Atbash cipher
- Caesar's cipher
- Homophonic substitution
- Morse code
- Pipeline of simple encryptors
- RSA cryptosystem
- Substitution cipher
- Vigenère cipher

# 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