cryptosystems


Namecryptosystems JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryA module for cryptography built from scratch, offering a robust suite of classes and functions for both symmetric and asymmetric encryption, as well as hashing functionalities
upload_time2024-10-27 20:34:26
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords cryptography encryption decryption hashing symmetric encryption asymmetric encryption cipher hash functions python cryptography lightweight cryptography dependency-free
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:
```bash
git clone https://github.com/ishan-surana/cryptosystems.git
cd cryptosystems
pip install -r requirements.txt
```

## Usage

**<details><summary> Symmetric Ciphers (Basic Cryptosystems)**</summary>

#### AdditiveCipher
```python
from cryptosystems import AdditiveCipher

cipher = AdditiveCipher(3)
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: 'Khoor Zruog'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

#### MultiplicativeCipher
```python
from cryptosystems import MultiplicativeCipher

cipher = MultiplicativeCipher(5)
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: 'Czggj Rjmgy'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

#### AffineCipher
```python
from cryptosystems import AffineCipher

cipher = AffineCipher(5, 8)
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: 'Rclla Oaplx'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

#### HillCipher
```python
from cryptosystems import HillCipher

cipher = HillCipher([[3, 3], [2, 5]])
ciphertext = cipher.encrypt("HelloWorld")
print(ciphertext)  # Output: 'HiozeIpjql'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'HelloWorld'
```

#### VigenereCipher
```python
from cryptosystems import VigenereCipher

cipher = VigenereCipher("key")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: 'Rijvs Uyvjk'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

#### PlayfairCipher
```python
from cryptosystems import PlayfairCipher

cipher = PlayfairCipher("key")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: 'Dahak Ldskn'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

#### AutoKeyCipher
```python
from cryptosystems import AutoKeyCipher

cipher = AutoKeyCipher("key")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: 'Rijss Hzfhr'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

</details>

**<details><summary> Symmetric Ciphers (Advanced Cryptosystems)**</summary>

#### DES
```python
from cryptosystems import DES

cipher = DES("password")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: b'\xf4\\V\x1a\xc7S\xb7\xdeZ\xc1\xe9\x14\n\x15Y\xe8'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

#### AES
```python
from cryptosystems import AES

cipher = AES("passwordpassword")
ciphertext = cipher.encrypt("Hello World")
print(ciphertext)  # Output: b'\x9cHS\xc2\x00\x0c\xba\x82Bj\x90\xc3t|4}'
plaintext = cipher.decrypt(ciphertext)
print(plaintext)  # Output: 'Hello World'
```

</details>

**<details><summary> Asymmetric Ciphers**</summary>

#### RSA
```python
from cryptosystems import RSA

rsa = RSA(1024)
ciphertext = rsa.encrypt(123)
print(ciphertext)  # Output: 1234567890
plaintext = rsa.decrypt(ciphertext)
print(plaintext)  # Output: 123
```

#### ElGamal
```python
from cryptosystems import ElGamal

elgamal = ElGamal(1024)
ciphertext = elgamal.encrypt(123)
print(ciphertext)  # Output: (123, 123)
plaintext = elgamal.decrypt(ciphertext)
print(plaintext)  # Output: 123
```

#### Rabin
```python
from cryptosystems import Rabin

rabin = Rabin(1024)
ciphertext = rabin.encrypt(123)
print(ciphertext)  # Output: 1234567890
plaintext = rabin.decrypt(ciphertext)
print(plaintext)  # Output: 123
```

#### Paillier
```python
from cryptosystems import Paillier

paillier = Paillier(1024)
ciphertext = paillier.encrypt(123)
print(ciphertext)  # Output: 1234567890
plaintext = paillier.decrypt(ciphertext)
print(plaintext)  # Output: 123
```

#### DiffieHellman
```python
from cryptosystems import DiffieHellman

diffiehellman = DiffieHellman()
shared_secret = diffiehellman.getSharedSecret()
print(shared_secret)  # Output: 1234567890
```

</details>

**<details><summary> Hash Functions**</summary>

#### MD5
```python
from cryptosystems import MD5

md5 = MD5()
hash_value = md5.hash("Hello World")
print(hash_value)  # Output: 'b10a8db164e0754105b7a99be72e3fe5'
```

#### SHA256
```python
from cryptosystems import SHA256

sha256 = SHA256()
hash_value = sha256.hash("Hello World")
print(hash_value)  # Output: 'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'
```

</details>

**<details><summary> Utility Functions**</summary>

#### getRandomInteger
```python
from cryptosystems import getRandomInteger

random_int = getRandomInteger(1024)
print(random_int)
```

#### getRandomRange
```python
from cryptosystems import getRandomRange

random_range = getRandomRange(1, 100)
print(random_range)
```

#### isPrime
```python
from cryptosystems import isPrime

prime_check = isPrime(17)
print(prime_check)  # Output: True
```

#### getPrime
```python
from cryptosystems import getPrime

prime_number = getPrime(1024)
print(prime_number)
```

</details>

## License
This project is licensed under the Apache License - see the [LICENSE](LICENCE) file for details.

## Authors
- **Ishan Surana** - *Inception, implementation and testing* - [GitHub](https://github.com/ishan-surana)

## Acknowledgments
- PyCryptodome, for the logic of functions in the [functions submodule](cryptosystems/functions.py)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cryptosystems",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Ishan Surana <ishansurana1234@gmail.com>",
    "keywords": "cryptography, encryption, decryption, hashing, symmetric encryption, asymmetric encryption, cipher, hash functions, Python cryptography, lightweight cryptography, dependency-free",
    "author": null,
    "author_email": "Ishan Surana <ishansurana1234@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/68/37/5dd744ca98b0777858c6d568a6ff8e8644f2f62f78e0c2b5f88456795133/cryptosystems-0.0.1.tar.gz",
    "platform": null,
    "description": "# Cryptosystems Package\r\n\r\n## Overview\r\nThe `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\u2019s 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.\r\n\r\n## Key Advantages\r\n- **Dependency-Free** \ud83d\udeab\ud83d\udce6: Operates solely on Python's built-in modules, eliminating the need for external libraries.\r\n- **Version Stability** \ud83d\udd12\ud83d\udcc5: Crafted to maintain consistent functionality across Python versions.\r\n- **Optimized for Performance** \u26a1\u2699\ufe0f: Built from scratch for efficient and consistant cryptographic operations.\r\n- **Lightweight Codebase** \ud83e\udeb6\ud83d\udcbb: Minimalistic design ensures a low overhead and straightforward integration.\r\n- **Reliability and Security** \ud83d\udd10\ud83d\udee1\ufe0f: Ensures robust encryption/decryption and hashing without reliance on third-party modules.\r\n- **Comprehensive Cryptosystem Support** \ud83d\udd04\ud83d\udd11: Offers a full suite of symmetric, asymmetric, and hashing methods.\r\n\r\n## Installation\r\nTo install the package, simply clone the repository and install the dependencies:\r\n```bash\r\ngit clone https://github.com/ishan-surana/cryptosystems.git\r\ncd cryptosystems\r\npip install -r requirements.txt\r\n```\r\n\r\n## Usage\r\n\r\n**<details><summary> Symmetric Ciphers (Basic Cryptosystems)**</summary>\r\n\r\n#### AdditiveCipher\r\n```python\r\nfrom cryptosystems import AdditiveCipher\r\n\r\ncipher = AdditiveCipher(3)\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: 'Khoor Zruog'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n#### MultiplicativeCipher\r\n```python\r\nfrom cryptosystems import MultiplicativeCipher\r\n\r\ncipher = MultiplicativeCipher(5)\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: 'Czggj Rjmgy'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n#### AffineCipher\r\n```python\r\nfrom cryptosystems import AffineCipher\r\n\r\ncipher = AffineCipher(5, 8)\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: 'Rclla Oaplx'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n#### HillCipher\r\n```python\r\nfrom cryptosystems import HillCipher\r\n\r\ncipher = HillCipher([[3, 3], [2, 5]])\r\nciphertext = cipher.encrypt(\"HelloWorld\")\r\nprint(ciphertext)  # Output: 'HiozeIpjql'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'HelloWorld'\r\n```\r\n\r\n#### VigenereCipher\r\n```python\r\nfrom cryptosystems import VigenereCipher\r\n\r\ncipher = VigenereCipher(\"key\")\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: 'Rijvs Uyvjk'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n#### PlayfairCipher\r\n```python\r\nfrom cryptosystems import PlayfairCipher\r\n\r\ncipher = PlayfairCipher(\"key\")\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: 'Dahak Ldskn'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n#### AutoKeyCipher\r\n```python\r\nfrom cryptosystems import AutoKeyCipher\r\n\r\ncipher = AutoKeyCipher(\"key\")\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: 'Rijss Hzfhr'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n</details>\r\n\r\n**<details><summary> Symmetric Ciphers (Advanced Cryptosystems)**</summary>\r\n\r\n#### DES\r\n```python\r\nfrom cryptosystems import DES\r\n\r\ncipher = DES(\"password\")\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: b'\\xf4\\\\V\\x1a\\xc7S\\xb7\\xdeZ\\xc1\\xe9\\x14\\n\\x15Y\\xe8'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n#### AES\r\n```python\r\nfrom cryptosystems import AES\r\n\r\ncipher = AES(\"passwordpassword\")\r\nciphertext = cipher.encrypt(\"Hello World\")\r\nprint(ciphertext)  # Output: b'\\x9cHS\\xc2\\x00\\x0c\\xba\\x82Bj\\x90\\xc3t|4}'\r\nplaintext = cipher.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 'Hello World'\r\n```\r\n\r\n</details>\r\n\r\n**<details><summary> Asymmetric Ciphers**</summary>\r\n\r\n#### RSA\r\n```python\r\nfrom cryptosystems import RSA\r\n\r\nrsa = RSA(1024)\r\nciphertext = rsa.encrypt(123)\r\nprint(ciphertext)  # Output: 1234567890\r\nplaintext = rsa.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 123\r\n```\r\n\r\n#### ElGamal\r\n```python\r\nfrom cryptosystems import ElGamal\r\n\r\nelgamal = ElGamal(1024)\r\nciphertext = elgamal.encrypt(123)\r\nprint(ciphertext)  # Output: (123, 123)\r\nplaintext = elgamal.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 123\r\n```\r\n\r\n#### Rabin\r\n```python\r\nfrom cryptosystems import Rabin\r\n\r\nrabin = Rabin(1024)\r\nciphertext = rabin.encrypt(123)\r\nprint(ciphertext)  # Output: 1234567890\r\nplaintext = rabin.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 123\r\n```\r\n\r\n#### Paillier\r\n```python\r\nfrom cryptosystems import Paillier\r\n\r\npaillier = Paillier(1024)\r\nciphertext = paillier.encrypt(123)\r\nprint(ciphertext)  # Output: 1234567890\r\nplaintext = paillier.decrypt(ciphertext)\r\nprint(plaintext)  # Output: 123\r\n```\r\n\r\n#### DiffieHellman\r\n```python\r\nfrom cryptosystems import DiffieHellman\r\n\r\ndiffiehellman = DiffieHellman()\r\nshared_secret = diffiehellman.getSharedSecret()\r\nprint(shared_secret)  # Output: 1234567890\r\n```\r\n\r\n</details>\r\n\r\n**<details><summary> Hash Functions**</summary>\r\n\r\n#### MD5\r\n```python\r\nfrom cryptosystems import MD5\r\n\r\nmd5 = MD5()\r\nhash_value = md5.hash(\"Hello World\")\r\nprint(hash_value)  # Output: 'b10a8db164e0754105b7a99be72e3fe5'\r\n```\r\n\r\n#### SHA256\r\n```python\r\nfrom cryptosystems import SHA256\r\n\r\nsha256 = SHA256()\r\nhash_value = sha256.hash(\"Hello World\")\r\nprint(hash_value)  # Output: 'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'\r\n```\r\n\r\n</details>\r\n\r\n**<details><summary> Utility Functions**</summary>\r\n\r\n#### getRandomInteger\r\n```python\r\nfrom cryptosystems import getRandomInteger\r\n\r\nrandom_int = getRandomInteger(1024)\r\nprint(random_int)\r\n```\r\n\r\n#### getRandomRange\r\n```python\r\nfrom cryptosystems import getRandomRange\r\n\r\nrandom_range = getRandomRange(1, 100)\r\nprint(random_range)\r\n```\r\n\r\n#### isPrime\r\n```python\r\nfrom cryptosystems import isPrime\r\n\r\nprime_check = isPrime(17)\r\nprint(prime_check)  # Output: True\r\n```\r\n\r\n#### getPrime\r\n```python\r\nfrom cryptosystems import getPrime\r\n\r\nprime_number = getPrime(1024)\r\nprint(prime_number)\r\n```\r\n\r\n</details>\r\n\r\n## License\r\nThis project is licensed under the Apache License - see the [LICENSE](LICENCE) file for details.\r\n\r\n## Authors\r\n- **Ishan Surana** - *Inception, implementation and testing* - [GitHub](https://github.com/ishan-surana)\r\n\r\n## Acknowledgments\r\n- PyCryptodome, for the logic of functions in the [functions submodule](cryptosystems/functions.py)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A module for cryptography built from scratch, offering a robust suite of classes and functions for both symmetric and asymmetric encryption, as well as hashing functionalities",
    "version": "0.0.1",
    "project_urls": {
        "Changelog": "https://github.com/ishan-surana/cryptosystems/releases",
        "Documentation": "https://cryptosystems.readthedocs.io/en/latest/",
        "Homepage": "https://cryptosystems.readthedocs.io/en/latest/",
        "Issues": "https://github.com/ishan-surana/cryptosystems/issues",
        "Repository": "https://github.com/ishan-surana/cryptosystems"
    },
    "split_keywords": [
        "cryptography",
        " encryption",
        " decryption",
        " hashing",
        " symmetric encryption",
        " asymmetric encryption",
        " cipher",
        " hash functions",
        " python cryptography",
        " lightweight cryptography",
        " dependency-free"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67cff2adc974fafe4b7b4f88565e0be1b77921947ed52faf0cba378cd7e6a122",
                "md5": "c427ccb628373339d0f6616c681916bc",
                "sha256": "ec78d8973028e382fbd3695d0e06573849eb83147b1c26de41ce18acc28a010f"
            },
            "downloads": -1,
            "filename": "cryptosystems-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c427ccb628373339d0f6616c681916bc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 24134,
            "upload_time": "2024-10-27T20:34:24",
            "upload_time_iso_8601": "2024-10-27T20:34:24.055975Z",
            "url": "https://files.pythonhosted.org/packages/67/cf/f2adc974fafe4b7b4f88565e0be1b77921947ed52faf0cba378cd7e6a122/cryptosystems-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68375dd744ca98b0777858c6d568a6ff8e8644f2f62f78e0c2b5f88456795133",
                "md5": "0b94a4c3716aa77dd5e469d0fbdb765a",
                "sha256": "09290aa6c909c69c8ef84ab99ad0210b9a3da1cef9908f98a71a6f839fe777b5"
            },
            "downloads": -1,
            "filename": "cryptosystems-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0b94a4c3716aa77dd5e469d0fbdb765a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 25313,
            "upload_time": "2024-10-27T20:34:26",
            "upload_time_iso_8601": "2024-10-27T20:34:26.091568Z",
            "url": "https://files.pythonhosted.org/packages/68/37/5dd744ca98b0777858c6d568a6ff8e8644f2f62f78e0c2b5f88456795133/cryptosystems-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-27 20:34:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ishan-surana",
    "github_project": "cryptosystems",
    "github_not_found": true,
    "lcname": "cryptosystems"
}
        
Elapsed time: 0.38745s