# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['blake2signer', 'blake2signer.hashers', 'blake2signer.tests']

package_data = \
{'': ['*']}

extras_require = \
{'blake3': ['blake3>0.2.0']}

setup_kwargs = {
    'name': 'blake2signer',
    'version': '2.4.0',
    'description': 'A library to use BLAKE in keyed hashing mode to sign and verify signed data',
    'long_description': '[![Pipeline Status](https://img.shields.io/gitlab/pipeline/hackancuba/blake2signer/develop?style=plastic)](https://gitlab.com/hackancuba/blake2signer/-/pipelines?page=1&scope=all&ref=develop)\n[![Coverage Report](https://img.shields.io/gitlab/coverage/hackancuba/blake2signer/develop?style=plastic)](https://gitlab.com/hackancuba/blake2signer/-/commits/develop)\n[![PyPI Version](https://img.shields.io/pypi/v/blake2signer?color=light%20green&style=plastic)](https://pypi.org/project/blake2signer)\n[![PyPI Python Versions](https://img.shields.io/pypi/pyversions/blake2signer?color=light%20green&style=plastic)](https://pypi.org/project/blake2signer)\n[![License](https://img.shields.io/pypi/l/blake2signer?color=light%20green&style=plastic)](https://gitlab.com/hackancuba/blake2signer/-/blob/main/LICENSE)\n[![Follow Me on Twitter](https://img.shields.io/twitter/follow/hackancuba?color=light%20green&style=plastic)](https://twitter.com/hackancuba)\n\n# ![Logo](https://assets.gitlab-static.net/uploads/-/system/project/avatar/21560006/icon_d_dark.png?width=40) Blake2Signer\n\nThe goal of this project is to provide a simple and straightforward way to securely sign data using [BLAKE in keyed hashing mode](https://docs.python.org/3/library/hashlib.html#keyed-hashing).\n\n## Why would I need to use it?\n\n* To sign data that needs to be sent through an untrusted channel, like signing a cookie with user data and providing it to the user, so the user can identify themselves with the rest of the system safely.\n* To save database lookups by checking signed data, like an account activation or password reset link where you can sign the user id and then verify it securely without using a database.\n* To prevent data tampering, like signing some value that goes in a form hidden field such as the user type (admin or regular) so that the user can\'t trick the value.\n* To easily express intent when signing data, like sharing a single secret key between signers to simplify app configuration and use the `personalisation` parameter to prevent signed data misuse.\n\nIn short, **never trust** user input, **always verify**. This module helps you do that.\n\n## Why would I want to use it?\n\nBecause it is a relatively *small* (around 900 logical lines of code, core around 400), *simple* (the public API has only a couple of methods) yet very *customizable* and *fast* data signer. My idea is to keep it as uncomplicated as possible without much room to become a *footgun*. All *defaults are very sane* (secure) and everything *just works* out of the box.\n\nThere are much better packages for other or more general use cases so if you feel this doesn\'t satisfy your needs please [leave a feature request](https://gitlab.com/hackancuba/blake2signer/-/issues) or consider using [itsdangerous](https://itsdangerous.palletsprojects.com), [Django\'s signer](https://docs.djangoproject.com/en/dev/topics/signing), [pypaseto](https://github.com/rlittlefield/pypaseto), [pyjwt](https://github.com/jpadilla/pyjwt) or others like those.\n\n## Goals\n\n* Be safe and secure.\n* Be simple and straightforward.\n* Follow [semver](https://semver.org/).\n* Be always typed.\n* No dependencies (besides dev).\n* 100% coverage.\n\n### Secondary goals\n\n* If possible, maintain current active Python versions (3.7+).\n\n## Installing\n\nThis package is hosted on [PyPi](https://pypi.org/project/blake2signer) so just:\n\n* `python3 -m pip install blake2signer`\n* `poetry add blake2signer`\n* `pipenv install blake2signer`\n\nYou can check the [releases\' page](https://gitlab.com/hackancuba/blake2signer/-/releases) for package hashes and signatures.\n\nNote: if you want to use BLAKE3, you need to install the [`blake3`](https://pypi.org/project/blake3/) package, until it arrives to core (which may or may not happen). Alternatively, you can install this package with extras:\n\n* `python3 -m pip install blake2signer[blake3]`\n* `poetry add blake2signer[blake3]`\n* `pipenv install blake2signer[blake3]`\n\n### Requirements\n\nOnly Python is required, this module doesn\'t have dependencies besides those used for development, and the optional `blake3`.\n\nVersions currently tested (check the [pipelines](https://gitlab.com/hackancuba/blake2signer/-/pipelines)):\n\n* CPython 3.7\n* CPython 3.8\n* CPython 3.9\n* CPython 3.10\n* CPython 3.11rc\n* [PyPy](https://www.pypy.org) 3.7\n    * If you are contributing to this project under PyPy, [read the contrib notes first](CONTRIB.md#working-under-pypy).\n* [PyPy](https://www.pypy.org) 3.8\n    * If you are contributing to this project under PyPy, [read the contrib notes first](CONTRIB.md#working-under-pypy).\n* [Stackless](https://github.com/stackless-dev/stackless/wiki) 3.7\n  * If you are contributing to this project under Stackless, [read the contrib notes first](CONTRIB.md#working-under-stackless).\n* [Stackless](https://github.com/stackless-dev/stackless/wiki) 3.8\n  * If you are contributing to this project under Stackless, [read the contrib notes first](CONTRIB.md#working-under-stackless).\n\n## Tl; Dr Example\n\n```python\n"""Tl;dr example."""\n\nfrom datetime import timedelta\n\nfrom blake2signer import Blake2SerializerSigner\nfrom blake2signer import errors\n\nsecret = b\'secure-secret-that-nobody-knows!\'\n# Some arbitrary data to sign\ndata = {\'user_id\': 1, \'is_admin\': True, \'username\': \'hackan\'}\n\nsigner = Blake2SerializerSigner(\n    secret,\n    max_age=timedelta(days=1),  # Add a timestamp to the signature\n    personalisation=b\'the-cookie-signer\',\n)\n\n# Sign and i.e. store the data in a cookie\nsigned = signer.dumps(data)  # Compression is enabled by default\n# If compressing data turns out to be detrimental then data won\'t be\n# compressed. If you know that from beforehand and don\'t need compression, you\n# can disable it:\n# signed = signer.dumps(data, compress=False)\n# Additionally, you can force compression nevertheless:\n# signed = signer.dumps(data, force_compression=True)\ncookie = {\'data\': signed}\n\n# To verify and recover data simply use `loads`: you will either get the data or\n# a `SignerError` subclass exception.\ntry:\n    unsigned = signer.loads(cookie.get(\'data\', \'\'))\nexcept errors.SignedDataError:  # See more about errors in the docs\n    # Can\'t trust on given data\n    unsigned = {}\n\nprint(unsigned)  # {\'user_id\': 1, \'is_admin\': True, \'username\': \'hackan\'}\n```\n\nFind more [details](https://blake2signer.hackan.net/en/stable/details) and [examples](https://blake2signer.hackan.net/en/stable/examples) in the docs.\n\n> Tip: all modules, classes, methods and functions are documented so don\'t doubt asking for `help()`.\n\n## Signers\n\nThis module provides three signer classes:\n\n* **Blake2SerializerSigner**: a signer class that handles data serialization, compression and encoding along with salted signing and salted timestamped signing. Its public methods are `dumps`, `loads`, `dumps_parts` and `loads_parts`, and `dump` and `load` for files.\n* **Blake2Signer**: a signer class that simply salts, signs and verifies signed data as bytes or string. Its public methods are `sign`, `unsign`, `sign_parts` and `unsign_parts`.\n* **Blake2TimestampSigner**: a signer class that simply salts, signs and verifies signed timestamped data as bytes or string. Its public methods are `sign`, `unsign`, `sign_parts` and `unsign_parts`.\n\n**You should generally go for Blake2SerializerSigner**, given that it\'s the most versatile of the three, unless you need to deal with plain bytes or string. Check [details about signers](https://blake2signer.hackan.net/en/stable/details) and [usage examples](https://blake2signer.hackan.net/en/stable/examples) to learn more.\n\n## Documentation\n\nCheck out this [project docs online](https://blake2signer.hackan.net) or locally with `inv docs`. Alternatively, build them locally using `inv docs --build`.\n\n## Notice\n\nI\'m not a cryptoexpert, so *this project needs a security review*. If you are one and can do it, please [contact me](https://hackan.net).\n\n## License\n\n**Blake2Signer** is made by [HacKan](https://hackan.net) under MPL v2.0. You are free to use, share, modify and share modifications under the terms of that [license](LICENSE).  Derived works may link back to the canonical repository: `https://gitlab.com/hackancuba/blake2signer`.\n\n    Copyright (C) 2020, 2021, 2022 HacKan (https://hackan.net)\n    This Source Code Form is subject to the terms of the Mozilla Public\n    License, v. 2.0. If a copy of the MPL was not distributed with this\n    file, You can obtain one at https://mozilla.org/MPL/2.0/.\n\n----\n\n[![CC BY-SA 4.0](https://i.creativecommons.org/l/by-sa/4.0/80x15.png)](https://creativecommons.org/licenses/by-sa/4.0/) *Blake2Signer icons* by [NoonSleeper](https://gitlab.com/noonsleeper) are licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/). You are free to use, share, modify and share modifications under the terms of that [license](https://creativecommons.org/licenses/by-sa/4.0/). They were based on *Blake2Signer logo* by [HacKan](https://hackan.net) which was based on [this sword](https://thenounproject.com/term/samurai-sword/2044449/) by *Hamza Wahbi* and [this signature](https://thenounproject.com/term/sign/184638/) by *Nick Bluth*, both licensed under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/), and inspired by [It\'s dangerous logo](https://itsdangerous.palletsprojects.com/en/1.1.x/_images/itsdangerous-logo.png).\n\nCheck them out in the [icons](https://gitlab.com/hackancuba/blake2signer/-/blob/develop/icons) subdir.\n',
    'author': 'HacKan',
    'author_email': 'hackan@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://gitlab.com/hackancuba/blake2signer',
    'packages': packages,
    'package_data': package_data,
    'extras_require': extras_require,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
