pyargon2


Namepyargon2 JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummarySimultaneously the simplest and most powerful Argon2 implemenation in Python
upload_time2024-08-24 14:56:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3
licenseApache2
keywords password hash hashing security argon2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyargon2

Simultaneously the simplest and most powerful implementation of Argon2 in Python.

## Installation 

```bash
pip install pyargon2
```

## Basic Usage

The hash function supports basic password hashing using the Argon2id variant and mandates password and salt strings. The resulting hash returned is hex encoded.

```python
from pyargon2 import hash

password = 'a strong password'
salt = 'a unique salt'
hex_encoded_hash = hash(password, salt)
```

The default parameters aim to generate hashes in around 0.5 seconds and are targeted at a machine housing a CPU with 4 cores and at least 4GB of RAM. If timing differs significantly on your machine, adjust the parameters using the advanced options below.
**Remember password hashing should be slow for security so don't optimise for speed!**

## Advanced Usage

### Function Choices

pyargon2 contains two functions for hashing. Namely, `hash` and `hash_bytes`. These two functions differ in their input types only.
This is explained in detail in the subsequent sections. To minimise input dependent hashing performance, dynamic type checking is not
used in pyargon2. Instead, dedicated functions are exposed to deal with hashing strings or byte arrays separately. As such, one should
ensure that they hash passwords, salts and peppers of the same type and then pick the corresponding function in pyargon2 as
appropriate.

### Function Parameters

The `hash` and `hash_bytes` functions take in the following parameters:

##### Positional

- **password** : A string (or byte array when using `hash_bytes`) representing a password.
- **salt** : A string (or byte array when using `hash_bytes`) representing a unique salt.

##### Keyword (Optional)

- **pepper** : A secret string (or byte array when using `hash_bytes`) to fold into the hash of the password.
- **hash_len** : The length in bytes of the resulting hash.
- **time_cost** : The number of iterations to perform.
- **memory_cost** : The number of kibibytes in memory to utilise.
- **parallelism** : The number of independent computations chains (lanes) to run.
- **flags** : Flags to determine which fields are securely wiped.
- **variant** : Argon2 algorithm variant ('i', 'd', or 'id').
- **version** : Argon2 algorithm version number.
- **encoding** : Encoding for the returned hash type ('raw', 'hex' or 'b64').

For assistance with parameter selection refer to [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106.html), in particular "Chapter 4: Parameter Choice".

### Function Exceptions

Exceptions generated by the underlying Argon2 hashing function are raised under the `Argon2Error` class which can be imported as follows:

```python
from pyargon2 import Argon2Error
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyargon2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "password, hash, hashing, security, argon2",
    "author": null,
    "author_email": "James Webb <james@ultra-horizon.com>",
    "download_url": "https://files.pythonhosted.org/packages/fa/f6/a283a5fd81ef66da0069cb31bfab6ada3318926ff9b6b2bf06c66c9f391b/pyargon2-1.1.0.tar.gz",
    "platform": null,
    "description": "# pyargon2\n\nSimultaneously the simplest and most powerful implementation of Argon2 in Python.\n\n## Installation \n\n```bash\npip install pyargon2\n```\n\n## Basic Usage\n\nThe hash function supports basic password hashing using the Argon2id variant and mandates password and salt strings. The resulting hash returned is hex encoded.\n\n```python\nfrom pyargon2 import hash\n\npassword = 'a strong password'\nsalt = 'a unique salt'\nhex_encoded_hash = hash(password, salt)\n```\n\nThe default parameters aim to generate hashes in around 0.5 seconds and are targeted at a machine housing a CPU with 4 cores and at least 4GB of RAM. If timing differs significantly on your machine, adjust the parameters using the advanced options below.\n**Remember password hashing should be slow for security so don't optimise for speed!**\n\n## Advanced Usage\n\n### Function Choices\n\npyargon2 contains two functions for hashing. Namely, `hash` and `hash_bytes`. These two functions differ in their input types only.\nThis is explained in detail in the subsequent sections. To minimise input dependent hashing performance, dynamic type checking is not\nused in pyargon2. Instead, dedicated functions are exposed to deal with hashing strings or byte arrays separately. As such, one should\nensure that they hash passwords, salts and peppers of the same type and then pick the corresponding function in pyargon2 as\nappropriate.\n\n### Function Parameters\n\nThe `hash` and `hash_bytes` functions take in the following parameters:\n\n##### Positional\n\n- **password** : A string (or byte array when using `hash_bytes`) representing a password.\n- **salt** : A string (or byte array when using `hash_bytes`) representing a unique salt.\n\n##### Keyword (Optional)\n\n- **pepper** : A secret string (or byte array when using `hash_bytes`) to fold into the hash of the password.\n- **hash_len** : The length in bytes of the resulting hash.\n- **time_cost** : The number of iterations to perform.\n- **memory_cost** : The number of kibibytes in memory to utilise.\n- **parallelism** : The number of independent computations chains (lanes) to run.\n- **flags** : Flags to determine which fields are securely wiped.\n- **variant** : Argon2 algorithm variant ('i', 'd', or 'id').\n- **version** : Argon2 algorithm version number.\n- **encoding** : Encoding for the returned hash type ('raw', 'hex' or 'b64').\n\nFor assistance with parameter selection refer to [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106.html), in particular \"Chapter 4: Parameter Choice\".\n\n### Function Exceptions\n\nExceptions generated by the underlying Argon2 hashing function are raised under the `Argon2Error` class which can be imported as follows:\n\n```python\nfrom pyargon2 import Argon2Error\n```\n",
    "bugtrack_url": null,
    "license": "Apache2",
    "summary": "Simultaneously the simplest and most powerful Argon2 implemenation in Python",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/ultrahorizon/pyargon2/issues",
        "Homepage": "https://github.com/ultrahorizon/pyargon2"
    },
    "split_keywords": [
        "password",
        " hash",
        " hashing",
        " security",
        " argon2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "faf6a283a5fd81ef66da0069cb31bfab6ada3318926ff9b6b2bf06c66c9f391b",
                "md5": "615848a1d900b7f3f25e9c9ab3be58ae",
                "sha256": "f5a759429c08ee220d95eafe99a2d14d60f0381885283c10ad9a45335ed868a7"
            },
            "downloads": -1,
            "filename": "pyargon2-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "615848a1d900b7f3f25e9c9ab3be58ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 58821,
            "upload_time": "2024-08-24T14:56:34",
            "upload_time_iso_8601": "2024-08-24T14:56:34.364555Z",
            "url": "https://files.pythonhosted.org/packages/fa/f6/a283a5fd81ef66da0069cb31bfab6ada3318926ff9b6b2bf06c66c9f391b/pyargon2-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-24 14:56:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ultrahorizon",
    "github_project": "pyargon2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyargon2"
}
        
Elapsed time: 0.28493s