encryptiontools


Nameencryptiontools JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/Smoren/encryptiontools-pypi
SummaryTools for encryption and decryption, signing and verification. Use symmetric and asymmetric (RSA-based) encryption.
upload_time2024-03-17 14:49:53
maintainer
docs_urlNone
authorSmoren
requires_python>=3.7
license
keywords cryptography encryption rsa signing verification symmetric asymmetric
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Encryption Tools for Python 3

[![PyPI package](https://img.shields.io/badge/pip%20install-encryptiontools-brightgreen)](https://pypi.org/project/encryptiontools/)
[![version number](https://img.shields.io/pypi/v/encryptiontools?color=green&label=version)](https://github.com/Smoren/encryptiontools-pypi/releases)
[![Coverage Status](https://coveralls.io/repos/github/Smoren/encryptiontools-pypi/badge.svg?branch=master)](https://coveralls.io/github/Smoren/encryptiontools-pypi?branch=master)
[![Actions Status](https://github.com/Smoren/encryptiontools-pypi/workflows/Test/badge.svg)](https://github.com/Smoren/encryptiontools-pypi/actions)
[![License](https://img.shields.io/github/license/Smoren/encryptiontools-pypi)](https://github.com/Smoren/encryptiontools-pypi/blob/master/LICENSE)

Tools for encryption and decryption, signing and verification. Use symmetric and asymmetric (RSA-based) encryption.

## Installation

```
pip install encryptiontools
```

## Usage

### Asymmetric encryption and decryption

```python
from encryptiontools.encryption import AsymmetricEncrypter, AsymmetricDecrypter
from encryptiontools.utils import generate_key_pair

public_key, private_key = generate_key_pair(512)

data = {'message': 'hello asymmetric encryption'}

encrypter = AsymmetricEncrypter.create(public_key.save_pkcs1())  # or AsymmetricEncrypter(public_key)
decrypter = AsymmetricDecrypter.create(private_key.save_pkcs1())  # or AsymmetricDecrypter(private_key)

encrypted = encrypter.encrypt(data)
decrypted = decrypter.decrypt(encrypted)

assert decrypted['message'] == 'hello asymmetric encryption'
```

### Symmetric encryption and decryption

```python
from encryptiontools.encryption import SymmetricEncrypter

key = b'0123456789abcdef'

data = {'message': 'hello symmetric encryption'}

encrypter = SymmetricEncrypter.create(key)  # or SymmetricEncrypter(key)

encrypted = encrypter.encrypt(data)
decrypted = encrypter.decrypt(encrypted)

assert decrypted['message'] == 'hello symmetric encryption'
```

### Combined encryption and decryption

Asymmetric key pair is used to encrypt/decrypt internal (symmetric) key, internal key is used to decrypt data.

```python
from encryptiontools.encryption import CombinedEncrypter, CombinedDecrypter
from encryptiontools.utils import generate_key_pair

public_key, private_key = generate_key_pair(512)

data = {'message': 'hello combined encryption'}

encrypter = CombinedEncrypter.create(public_key.save_pkcs1())  # or CombinedEncrypter(public_key)
decrypter = CombinedDecrypter.create(private_key.save_pkcs1())  # or CombinedDecrypter(private_key)

encrypted = encrypter.encrypt(data)
decrypted = decrypter.decrypt(encrypted)

assert decrypted['message'] == 'hello combined encryption'
```

### Signing and verification

```python
from encryptiontools.signature import Signer, Verifier
from encryptiontools.utils import generate_key_pair
from encryptiontools.exceptions import VerificationError

public_key, private_key = generate_key_pair(512)

data = {'message': 'hello signing and verification'}

signer = Signer.create(private_key.save_pkcs1())  # or Signer(private_key)
verifier = Verifier.create(public_key.save_pkcs1())  # or Verifier(public_key)

signature = signer.sign(data)

try:
  verifier.verify(data, signature)
  assert True
except VerificationError:
  assert False
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Smoren/encryptiontools-pypi",
    "name": "encryptiontools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "cryptography,encryption,rsa,signing,verification,symmetric,asymmetric",
    "author": "Smoren",
    "author_email": "ofigate@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b7/30/fd2f1fa30163f283b177acc330d5f5907713cd2c395a5dbb1510b4418e12/encryptiontools-1.0.0.tar.gz",
    "platform": null,
    "description": "# Encryption Tools for Python 3\n\n[![PyPI package](https://img.shields.io/badge/pip%20install-encryptiontools-brightgreen)](https://pypi.org/project/encryptiontools/)\n[![version number](https://img.shields.io/pypi/v/encryptiontools?color=green&label=version)](https://github.com/Smoren/encryptiontools-pypi/releases)\n[![Coverage Status](https://coveralls.io/repos/github/Smoren/encryptiontools-pypi/badge.svg?branch=master)](https://coveralls.io/github/Smoren/encryptiontools-pypi?branch=master)\n[![Actions Status](https://github.com/Smoren/encryptiontools-pypi/workflows/Test/badge.svg)](https://github.com/Smoren/encryptiontools-pypi/actions)\n[![License](https://img.shields.io/github/license/Smoren/encryptiontools-pypi)](https://github.com/Smoren/encryptiontools-pypi/blob/master/LICENSE)\n\nTools for encryption and decryption, signing and verification. Use symmetric and asymmetric (RSA-based) encryption.\n\n## Installation\n\n```\npip install encryptiontools\n```\n\n## Usage\n\n### Asymmetric encryption and decryption\n\n```python\nfrom encryptiontools.encryption import AsymmetricEncrypter, AsymmetricDecrypter\nfrom encryptiontools.utils import generate_key_pair\n\npublic_key, private_key = generate_key_pair(512)\n\ndata = {'message': 'hello asymmetric encryption'}\n\nencrypter = AsymmetricEncrypter.create(public_key.save_pkcs1())  # or AsymmetricEncrypter(public_key)\ndecrypter = AsymmetricDecrypter.create(private_key.save_pkcs1())  # or AsymmetricDecrypter(private_key)\n\nencrypted = encrypter.encrypt(data)\ndecrypted = decrypter.decrypt(encrypted)\n\nassert decrypted['message'] == 'hello asymmetric encryption'\n```\n\n### Symmetric encryption and decryption\n\n```python\nfrom encryptiontools.encryption import SymmetricEncrypter\n\nkey = b'0123456789abcdef'\n\ndata = {'message': 'hello symmetric encryption'}\n\nencrypter = SymmetricEncrypter.create(key)  # or SymmetricEncrypter(key)\n\nencrypted = encrypter.encrypt(data)\ndecrypted = encrypter.decrypt(encrypted)\n\nassert decrypted['message'] == 'hello symmetric encryption'\n```\n\n### Combined encryption and decryption\n\nAsymmetric key pair is used to encrypt/decrypt internal (symmetric) key, internal key is used to decrypt data.\n\n```python\nfrom encryptiontools.encryption import CombinedEncrypter, CombinedDecrypter\nfrom encryptiontools.utils import generate_key_pair\n\npublic_key, private_key = generate_key_pair(512)\n\ndata = {'message': 'hello combined encryption'}\n\nencrypter = CombinedEncrypter.create(public_key.save_pkcs1())  # or CombinedEncrypter(public_key)\ndecrypter = CombinedDecrypter.create(private_key.save_pkcs1())  # or CombinedDecrypter(private_key)\n\nencrypted = encrypter.encrypt(data)\ndecrypted = decrypter.decrypt(encrypted)\n\nassert decrypted['message'] == 'hello combined encryption'\n```\n\n### Signing and verification\n\n```python\nfrom encryptiontools.signature import Signer, Verifier\nfrom encryptiontools.utils import generate_key_pair\nfrom encryptiontools.exceptions import VerificationError\n\npublic_key, private_key = generate_key_pair(512)\n\ndata = {'message': 'hello signing and verification'}\n\nsigner = Signer.create(private_key.save_pkcs1())  # or Signer(private_key)\nverifier = Verifier.create(public_key.save_pkcs1())  # or Verifier(public_key)\n\nsignature = signer.sign(data)\n\ntry:\n  verifier.verify(data, signature)\n  assert True\nexcept VerificationError:\n  assert False\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Tools for encryption and decryption, signing and verification. Use symmetric and asymmetric (RSA-based) encryption.",
    "version": "1.0.0",
    "project_urls": {
        "Bug Reports": "https://github.com/Smoren/encryptiontools-pypi/issues",
        "Documentation": "https://github.com/Smoren/encryptiontools-pypi",
        "Homepage": "https://github.com/Smoren/encryptiontools-pypi",
        "Source Code": "https://github.com/Smoren/encryptiontools-pypi"
    },
    "split_keywords": [
        "cryptography",
        "encryption",
        "rsa",
        "signing",
        "verification",
        "symmetric",
        "asymmetric"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64c4c758efc105f80b2b8f5150b84b9444d76cedd7f88725f19937c22d95bf0b",
                "md5": "235addf1bbcf39707c301db189cb7e71",
                "sha256": "41f65b88178d582f08f890091b8f229a5fa83500f1acbe0f224315cf88a6bacd"
            },
            "downloads": -1,
            "filename": "encryptiontools-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "235addf1bbcf39707c301db189cb7e71",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6823,
            "upload_time": "2024-03-17T14:49:51",
            "upload_time_iso_8601": "2024-03-17T14:49:51.296523Z",
            "url": "https://files.pythonhosted.org/packages/64/c4/c758efc105f80b2b8f5150b84b9444d76cedd7f88725f19937c22d95bf0b/encryptiontools-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b730fd2f1fa30163f283b177acc330d5f5907713cd2c395a5dbb1510b4418e12",
                "md5": "60458e2dc6c5c3f0573408cfc8de3304",
                "sha256": "9e58547e4dabc59e750f2e7a690d2efec3181cd26d1bbc41a5b24587068154be"
            },
            "downloads": -1,
            "filename": "encryptiontools-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "60458e2dc6c5c3f0573408cfc8de3304",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6881,
            "upload_time": "2024-03-17T14:49:53",
            "upload_time_iso_8601": "2024-03-17T14:49:53.035298Z",
            "url": "https://files.pythonhosted.org/packages/b7/30/fd2f1fa30163f283b177acc330d5f5907713cd2c395a5dbb1510b4418e12/encryptiontools-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-17 14:49:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Smoren",
    "github_project": "encryptiontools-pypi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "encryptiontools"
}
        
Elapsed time: 0.24024s