PyFLocker


NamePyFLocker JSON
Version 0.4.2 PyPI version JSON
download
home_pageNone
SummaryPython Cryptographic (File Locking) Library
upload_time2024-04-19 11:34:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords cryptography encryption python pypi symmetric key asymmetric key aes chacha20 camellia rsa dsa ecc file encryption secure communication cryptography library
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyFLocker

[![CI](https://github.com/arunanshub/pyflocker/actions/workflows/ci.yml/badge.svg)](https://github.com/arunanshub/pyflocker/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/arunanshub/pyflocker/badge.svg?branch=master)](https://coveralls.io/github/arunanshub/pyflocker?branch=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Python Versions](https://img.shields.io/pypi/pyversions/PyFLocker?label=Python%20Versions)](https://pypi.org/project/PyFLocker)
[![Documentation Status](https://readthedocs.org/projects/pyflocker/badge/?version=latest)](https://pyflocker.readthedocs.io/en/latest/?badge=latest)

Python Cryptographic (File Locking) Library

> Lock as in Lock and Key.

## Installation

Use `pip` or `pip3` to install PyFLocker

    pip install pyflocker

or

    pip3 install pyflocker

## Introduction

PyFLocker aims to be a highly stable and easy to use cryptographic library.
Before you read on, check if you agree to at least one of these points:

- [`PyCryptodome(x)`][pycrypto] and [`pyca/cryptography`][pyca] have
  **very different** public interfaces, which makes remembering all the imports
  very difficult, and leaves you reading docs under deadline.

- The interface of `pyca/cryptography` is very difficult to use, let alone
  remember the import:

  ```python
  from cryptography.hazmat.primitives.ciphers.algorithms import AES
  from cryptography.hazmat.primitives.ciphers import Modes
  ...
  from cryptography.hazmat.backends import default_backend
  # and so on...
  ```

- You wish that only if `pyca/cryptography` had been as easy to use as
  `Pycryptodome(x)`, it would have made life more easy.

- You sometimes think that the file encryption script you wrote were somehow
  faster and played with both backends very well, but you weren't sure what to do.

  - And all the other solutions (and nonsolutions!) on the internet just confuses
    you more!

PyFLocker uses well established libraries as its backends and expands upon them.
This gives you the ultimate ability to cherry-pick the primitives from a specific
backend without having to worry about backend itself, as PyFLocker handles it
for you.

You can find more information in the [documentation][docs].

## Features

### Not a "Yet Another Cryptographic Library"

PyFLocker provides you a seamless interface to both the backends, and switching
is very easy:

```python
import os
from pyflocker.ciphers import AES, RSA, ECC
from pyflocker.ciphers.backends import Backends

key, nonce = os.urandom(32), os.urandom(16)

# Multiple backends - same API
enc = AES.new(True, key, AES.MODE_EAX, nonce, backend=Backends.CRYPTOGRAPHY)
rpriv = RSA.generate(2048, backend=Backends.CRYPTODOME)
epriv = ECC.generate("x25519", backend=Backends.CRYPTOGRAPHY)
```

Backend loading is done internally, and if a backend is explicitly specified,
that is used as the default.

### Ease of Use

PyFLocker provides reasonable defaults wherever possible:

```python
from pyflocker.ciphers import RSA
priv = RSA.generate(2048)
with open("private_key.pem", "xb") as f:
    key = priv.serialize(passphrase=b"random-chimp-event")
    f.write(key)
```

Don't believe me, try to do the [same operation with `pyca/cryptography`][pyca_vs_self],
or just any other initialization.

In short, the API is very stable, clear and easy on developer's mind.

### Writing into file or file-like objects

This is often a related problem when it comes to encryption, but think no more!

```python
import os
from pyflocker.ciphers import AES
from pyflocker.ciphers.backends import Backends

key, nonce = os.urandom(32), os.urandom(16)
f1 = open("MySecretData.txt", "rb")
f2 = open("MySecretData.txt.enc", "xb")
enc = AES.new(
    True,
    key,
    AES.MODE_EAX,
    nonce,
    backend=Backends.CRYPTOGRAPHY,
    file=f1,
)
enc.update_into(f2)
tag = enc.calculate_tag()
```

You can also use `BytesIO` in place of file objects.

### Directly encrypting files

Just want to encrypt your file with AES, and even with various available modes?

```python
from pyflocker.locker import locker
from pyflocker.ciphers import AES

password = b"no not this"
locker(
    "./MySuperSecretFile.txt",
    password,
    aes_mode=AES.MODE_CTR,  # default is AES-GCM-256
)
# file stored as MySuperSecretFile.txt.pyflk
```

Find more examples [here][examples].

## License

[MIT](https://choosealicense.com/licenses/mit/)

[docs]: https://pyflocker.readthedocs.io/en/latest/
[examples]: https://pyflocker.readthedocs.io/en/latest/examples
[pycrypto]: https://github.com/Legrandin/pycryptodome
[pyca]: https://github.com/pyca/cryptography
[pyca_vs_self]: https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa.html#key-serialization

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyFLocker",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "cryptography, encryption, python, pypi, symmetric key, asymmetric key, aes, chacha20, camellia, rsa, dsa, ecc, file encryption, secure communication, cryptography library",
    "author": null,
    "author_email": "Arunanshu Biswas <mydellpc07@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4a/d5/30f119f265099073f881cc5e629e34e2c95e37770e9b769789dacc2c2a32/pyflocker-0.4.2.tar.gz",
    "platform": null,
    "description": "# PyFLocker\n\n[![CI](https://github.com/arunanshub/pyflocker/actions/workflows/ci.yml/badge.svg)](https://github.com/arunanshub/pyflocker/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/arunanshub/pyflocker/badge.svg?branch=master)](https://coveralls.io/github/arunanshub/pyflocker?branch=master)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/PyFLocker?label=Python%20Versions)](https://pypi.org/project/PyFLocker)\n[![Documentation Status](https://readthedocs.org/projects/pyflocker/badge/?version=latest)](https://pyflocker.readthedocs.io/en/latest/?badge=latest)\n\nPython Cryptographic (File Locking) Library\n\n> Lock as in Lock and Key.\n\n## Installation\n\nUse `pip` or `pip3` to install PyFLocker\n\n    pip install pyflocker\n\nor\n\n    pip3 install pyflocker\n\n## Introduction\n\nPyFLocker aims to be a highly stable and easy to use cryptographic library.\nBefore you read on, check if you agree to at least one of these points:\n\n- [`PyCryptodome(x)`][pycrypto] and [`pyca/cryptography`][pyca] have\n  **very different** public interfaces, which makes remembering all the imports\n  very difficult, and leaves you reading docs under deadline.\n\n- The interface of `pyca/cryptography` is very difficult to use, let alone\n  remember the import:\n\n  ```python\n  from cryptography.hazmat.primitives.ciphers.algorithms import AES\n  from cryptography.hazmat.primitives.ciphers import Modes\n  ...\n  from cryptography.hazmat.backends import default_backend\n  # and so on...\n  ```\n\n- You wish that only if `pyca/cryptography` had been as easy to use as\n  `Pycryptodome(x)`, it would have made life more easy.\n\n- You sometimes think that the file encryption script you wrote were somehow\n  faster and played with both backends very well, but you weren't sure what to do.\n\n  - And all the other solutions (and nonsolutions!) on the internet just confuses\n    you more!\n\nPyFLocker uses well established libraries as its backends and expands upon them.\nThis gives you the ultimate ability to cherry-pick the primitives from a specific\nbackend without having to worry about backend itself, as PyFLocker handles it\nfor you.\n\nYou can find more information in the [documentation][docs].\n\n## Features\n\n### Not a \"Yet Another Cryptographic Library\"\n\nPyFLocker provides you a seamless interface to both the backends, and switching\nis very easy:\n\n```python\nimport os\nfrom pyflocker.ciphers import AES, RSA, ECC\nfrom pyflocker.ciphers.backends import Backends\n\nkey, nonce = os.urandom(32), os.urandom(16)\n\n# Multiple backends - same API\nenc = AES.new(True, key, AES.MODE_EAX, nonce, backend=Backends.CRYPTOGRAPHY)\nrpriv = RSA.generate(2048, backend=Backends.CRYPTODOME)\nepriv = ECC.generate(\"x25519\", backend=Backends.CRYPTOGRAPHY)\n```\n\nBackend loading is done internally, and if a backend is explicitly specified,\nthat is used as the default.\n\n### Ease of Use\n\nPyFLocker provides reasonable defaults wherever possible:\n\n```python\nfrom pyflocker.ciphers import RSA\npriv = RSA.generate(2048)\nwith open(\"private_key.pem\", \"xb\") as f:\n    key = priv.serialize(passphrase=b\"random-chimp-event\")\n    f.write(key)\n```\n\nDon't believe me, try to do the [same operation with `pyca/cryptography`][pyca_vs_self],\nor just any other initialization.\n\nIn short, the API is very stable, clear and easy on developer's mind.\n\n### Writing into file or file-like objects\n\nThis is often a related problem when it comes to encryption, but think no more!\n\n```python\nimport os\nfrom pyflocker.ciphers import AES\nfrom pyflocker.ciphers.backends import Backends\n\nkey, nonce = os.urandom(32), os.urandom(16)\nf1 = open(\"MySecretData.txt\", \"rb\")\nf2 = open(\"MySecretData.txt.enc\", \"xb\")\nenc = AES.new(\n    True,\n    key,\n    AES.MODE_EAX,\n    nonce,\n    backend=Backends.CRYPTOGRAPHY,\n    file=f1,\n)\nenc.update_into(f2)\ntag = enc.calculate_tag()\n```\n\nYou can also use `BytesIO` in place of file objects.\n\n### Directly encrypting files\n\nJust want to encrypt your file with AES, and even with various available modes?\n\n```python\nfrom pyflocker.locker import locker\nfrom pyflocker.ciphers import AES\n\npassword = b\"no not this\"\nlocker(\n    \"./MySuperSecretFile.txt\",\n    password,\n    aes_mode=AES.MODE_CTR,  # default is AES-GCM-256\n)\n# file stored as MySuperSecretFile.txt.pyflk\n```\n\nFind more examples [here][examples].\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n[docs]: https://pyflocker.readthedocs.io/en/latest/\n[examples]: https://pyflocker.readthedocs.io/en/latest/examples\n[pycrypto]: https://github.com/Legrandin/pycryptodome\n[pyca]: https://github.com/pyca/cryptography\n[pyca_vs_self]: https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa.html#key-serialization\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Cryptographic (File Locking) Library",
    "version": "0.4.2",
    "project_urls": {
        "Bug tracker": "https://github.com/arunanshub/pyflocker/issues",
        "Changelog": "https://github.com/arunanshub/pyflocker/blob/master/CHANGELOG.md",
        "Documentation": "https://pyflocker.readthedocs.io",
        "Repository": "https://github.com/arunanshub/pyflocker"
    },
    "split_keywords": [
        "cryptography",
        " encryption",
        " python",
        " pypi",
        " symmetric key",
        " asymmetric key",
        " aes",
        " chacha20",
        " camellia",
        " rsa",
        " dsa",
        " ecc",
        " file encryption",
        " secure communication",
        " cryptography library"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3bc14da9de475d391a2b9821efbaa621965992e40bcfe8f7bf55f925f7e5e954",
                "md5": "0831affacfd4506b2ddef06a97e94f7a",
                "sha256": "39aeb7853acbfe991e29c4bf95c481fb324d6dff2f050ee1e2767aedfbd95ad7"
            },
            "downloads": -1,
            "filename": "pyflocker-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0831affacfd4506b2ddef06a97e94f7a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 68891,
            "upload_time": "2024-04-19T11:34:20",
            "upload_time_iso_8601": "2024-04-19T11:34:20.586191Z",
            "url": "https://files.pythonhosted.org/packages/3b/c1/4da9de475d391a2b9821efbaa621965992e40bcfe8f7bf55f925f7e5e954/pyflocker-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ad530f119f265099073f881cc5e629e34e2c95e37770e9b769789dacc2c2a32",
                "md5": "69149bf43ec780672263baa8aa778b7c",
                "sha256": "9d7cd849c852f4ce803548478bd3d6e4510541dec76702ca6f9599407ab4cea1"
            },
            "downloads": -1,
            "filename": "pyflocker-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "69149bf43ec780672263baa8aa778b7c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 67802,
            "upload_time": "2024-04-19T11:34:21",
            "upload_time_iso_8601": "2024-04-19T11:34:21.898393Z",
            "url": "https://files.pythonhosted.org/packages/4a/d5/30f119f265099073f881cc5e629e34e2c95e37770e9b769789dacc2c2a32/pyflocker-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 11:34:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arunanshub",
    "github_project": "pyflocker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyflocker"
}
        
Elapsed time: 0.22769s