Skip to main content

A library for various cryptography algorithms (Caesar, Hill Cipher.)

Project description

Cryptography Library

Python License Version

A Python library for implementing and working with various classical encryption algorithms. This library provides a collection of ciphers that you can use to encrypt and decrypt data in educational or practical cryptography-related projects.


Features

This library includes the following classical ciphers:

  • Caesar Cipher: A substitution cipher that shifts letters by a fixed number.
  • Monoalphabetic Cipher: A substitution cipher where each character is replaced by another character using a key.
  • Vigenere Cipher: A polyalphabetic substitution cipher that uses a keyword to encrypt data.
  • Vernam Cipher: A stream cipher that uses a key of the same length as the plaintext for encryption.
  • Playfair Cipher: A digraph substitution cipher that encrypts pairs of letters.
  • Hill Cipher: A cipher based on linear algebra that uses matrix multiplication for encryption.

Installation

You can install this library using pip (after uploading it to PyPI):

pip install CryptoClasec

Usage

Here’s how to use the library in your Python project:

Import the Cipher Classes

from CryptoClasec import Caesar, Monoalphabetic, Vigenere, Vernam, Playfair, HillCipher

Example: Caesar Cipher

# Initialize the Caesar cipher with a shift value of 3
caesar = Caesar(3)

# Encrypt a plaintext
encrypted = caesar.encrypt("HELLO")
print("Encrypted text:", encrypted)

# Decrypt the ciphertext
decrypted = caesar.decrypt(encrypted)
print("Decrypted text:", decrypted)

Example: Vigenere Cipher

# Initialize the Vigenere cipher with a keyword
vigenere = Vigenere("KEY")

# Encrypt a plaintext
encrypted = vigenere.encrypt("HELLO")
print("Encrypted text:", encrypted)

# Decrypt the ciphertext
decrypted = vigenere.decrypt(encrypted)
print("Decrypted text:", decrypted)

Available Classes

1- Caesar:

caesar = Caesar(3)
caesar.encrypt(plaintext)
caesar.decrypt(ciphertext)

2- Monoalphabetic:

mono = Monoalphabetic("QWERTYUIOPLKJHGFDSAZXCVBNM")
mono.encrypt(plaintext)
mono.decrypt(ciphertext)

2- Vigenere:

vigenere = Vigenere("KEY")
vigenere.encrypt(plaintext)
vigenere.decrypt(ciphertext)

4- Vernam:

vernam = Vernam("RANDOMKEY")
vernam.encrypt(plaintext)
vernam.decrypt(ciphertext)

5- Playfair:

playfair = Playfair("KEYWORD")
playfair.encrypt(plaintext)
playfair.decrypt(ciphertext)

6- HillCipher:

hill = HillCipher([[2, 3], [1, 4]])
hill.encrypt(plaintext)
hill.decrypt(ciphertext)

License

This library is licensed under the MIT License. See the LICENSE file for more information.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve the library.

Author

Created by Ibrahem abo kila. For any inquiries, please contact me at ibrahemabokila@gmail.com.

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

cryptoclasec-1.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

CryptoClasec-1.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file cryptoclasec-1.0.1.tar.gz.

File metadata

  • Download URL: cryptoclasec-1.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for cryptoclasec-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d954e9579bf22be30feadc24b23be9d4c97fec92a6dfc69549871ceb96f6b12a
MD5 f8169799d3de54fcb23b185c49694532
BLAKE2b-256 4269fb2c205243a147adb13b0bc175885aaf84b735b958c6cabc92f90e7d8cca

See more details on using hashes here.

File details

Details for the file CryptoClasec-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: CryptoClasec-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for CryptoClasec-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ba54d8771f5b66dbd36c5b56edf11a61c6b6faf7e9080f94222108f07b475ab
MD5 443d63362a662366d1d9d32c7e6adf01
BLAKE2b-256 a5dd74d46e43776bd920a294f6a889b912d622378eb08396941a54e658d5a346

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