Cryptosystems Package
Overview
The cryptosystems
package offers a robust suite of classes and functions for both symmetric and asymmetric encryption, as well as hashing functionalities. Designed for seamless encryption, decryption, and cryptographic operations, this package is lightweight and efficient, relying solely on Python’s built-in libraries: os
and hashlib
. With all cryptographic logic implemented from scratch, cryptosystems provides a streamlined, dependency-free solution, ensuring consistency and reliability across different environments as well as Python versions.
Key Advantages
- Dependency-Free 🚫📦: Operates solely on Python's built-in modules, eliminating the need for external libraries.
- Version Stability 🔒📅: Crafted to maintain consistent functionality across Python versions.
- Optimized for Performance ⚡⚙️: Built from scratch for efficient and consistant cryptographic operations.
- Lightweight Codebase 🪶💻: Minimalistic design ensures a low overhead and straightforward integration.
- Reliability and Security 🔐🛡️: Ensures robust encryption/decryption and hashing without reliance on third-party modules.
- Comprehensive Cryptosystem Support 🔄🔑: Offers a full suite of symmetric, asymmetric, and hashing methods.
Installation
To install the package, simply clone the repository and install the dependencies:
git clone https://github.com/ishan-surana/cryptosystems.git
cd cryptosystems
pip install -r requirements.txt
Usage
Symmetric Ciphers (Basic Cryptosystems)
AdditiveCipher
from cryptosystems import AdditiveCipher
cipher = AdditiveCipher(3)
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
MultiplicativeCipher
from cryptosystems import MultiplicativeCipher
cipher = MultiplicativeCipher(5)
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
AffineCipher
from cryptosystems import AffineCipher
cipher = AffineCipher(5, 8)
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
HillCipher
from cryptosystems import HillCipher
cipher = HillCipher([[3, 3], [2, 5]])
ciphertext = cipher.encrypt("HelloWorld")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
VigenereCipher
from cryptosystems import VigenereCipher
cipher = VigenereCipher("key")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
PlayfairCipher
from cryptosystems import PlayfairCipher
cipher = PlayfairCipher("key")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
AutoKeyCipher
from cryptosystems import AutoKeyCipher
cipher = AutoKeyCipher("key")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
Symmetric Ciphers (Advanced Cryptosystems)
DES
from cryptosystems import DES
cipher = DES("password")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
AES
from cryptosystems import AES
cipher = AES("passwordpassword")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)
Asymmetric Ciphers
RSA
from cryptosystems import RSA
rsa = RSA(1024)
ciphertext = rsa.encrypt(123)
print(ciphertext)
plaintext = rsa.decrypt(ciphertext)
print(plaintext)
ElGamal
from cryptosystems import ElGamal
elgamal = ElGamal(1024)
ciphertext = elgamal.encrypt(123)
print(ciphertext)
plaintext = elgamal.decrypt(ciphertext)
print(plaintext)
Rabin
from cryptosystems import Rabin
rabin = Rabin(1024)
ciphertext = rabin.encrypt(123)
print(ciphertext)
plaintext = rabin.decrypt(ciphertext)
print(plaintext)
Paillier
from cryptosystems import Paillier
paillier = Paillier(1024)
ciphertext = paillier.encrypt(123)
print(ciphertext)
plaintext = paillier.decrypt(ciphertext)
print(plaintext)
DiffieHellman
from cryptosystems import DiffieHellman
diffiehellman = DiffieHellman()
shared_secret = diffiehellman.getSharedSecret()
print(shared_secret)
Hash Functions
MD5
from cryptosystems import MD5
md5 = MD5()
hash_value = md5.hash("Hello World")
print(hash_value)
SHA256
from cryptosystems import SHA256
sha256 = SHA256()
hash_value = sha256.hash("Hello World")
print(hash_value)
Utility Functions
getRandomInteger
from cryptosystems import getRandomInteger
random_int = getRandomInteger(1024)
print(random_int)
getRandomRange
from cryptosystems import getRandomRange
random_range = getRandomRange(1, 100)
print(random_range)
isPrime
from cryptosystems import isPrime
prime_check = isPrime(17)
print(prime_check)
getPrime
from cryptosystems import getPrime
prime_number = getPrime(1024)
print(prime_number)
License
This project is licensed under the Apache License - see the LICENSE file for details.
Authors
- Ishan Surana - Inception, implementation and testing - GitHub
Acknowledgments