seedrandom


Nameseedrandom JSON
Version 2.3.1 PyPI version JSON
download
home_pagehttps://github.com/BananaLoaf/seedrandom
SummaryProof-of-concept seeded RNG lib
upload_time2023-09-08 23:58:44
maintainerBananaLoaf
docs_urlNone
authorBananaLoaf
requires_python>=3.7,<4.0
licenseMIT
keywords random seed seeded number generator hash int float bool bytes rng deterministic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # seedrandom
Deterministic seeded RNG

[![Python Version](https://img.shields.io/pypi/pyversions/seedrandom.svg?color=yellow&style=flat-square)](https://www.python.org/downloads/)
[![GitHub Licence](https://img.shields.io/github/license/BananaLoaf/seedrandom.svg?color=blue&style=flat-square)](https://github.com/BananaLoaf/seedrandom/blob/master/LICENSE)
[![Package Version](https://img.shields.io/pypi/v/seedrandom.svg?color=green&style=flat-square)](https://pypi.org/project/seedrandom/)


### Installation / Updating
```
pip install seedrandom
pip install --upgrade seedrandom
```
Or
```
pip install git+https://github.com/BananaLoaf/seedrandom.git
pip install --upgrade git+https://github.com/BananaLoaf/seedrandom.git
```

### Usage

```python
from seedrandom import SeededRNG
rng = SeededRNG(b"Test", b"values", hash_func=hashlib.sha512)  # any hash func from hashlib
```

Generating random values:
```python
rng.randint(a=0, b=1000)  # 893
rng.randfloat(a=0, b=100, step=0.1)  # 89.3
rng.randbool()  # False
rng.randbyte()  # b'\xbf'
```

```SeededRNG``` can be converted to and from ```int``` or ```bytes```:
```python
bytes(rng)
int(rng)

rng1 = SeededRNG.from_bytes(b'\xbb\x9a\xf3\xe3\x1d\xfcA\xcc\xc5\x93S\x9a\xec:\x9a\x08z\x88\x85\x99\xf7\xea\x91\xb6x\x00\xfb\x82"\xc2$K', hash_func=hashlib.blake2s)
rng2 = SeededRNG.from_int(13391421701272821393603640485300504071883816826531413055648909144818643814535822212998295950921452703111178763035507290455800978052021014498426299707601814, hash_func=hashlib.sha512)
```

```ordered``` parameter can be used:
```python
rng1 = SeededRNG(b"Hello", b"world")
rng2 = SeededRNG(b"world", b"Hello")
rng1 == rng2  # True

rng1 = SeededRNG(ordered=(b"Hello", b"world"))
rng2 = SeededRNG(ordered=(b"world", b"Hello"))
rng1 == rng2  # False

rng1 = SeededRNG(b"Hello", b"world", ordered=(b"spanish", b"inquisition"))
rng2 = SeededRNG(b"world", b"Hello", ordered=(b"spanish", b"inquisition"))
rng1 == rng2  # True

rng1 = SeededRNG(b"Hello", b"world", ordered=(b"spanish", b"inquisition"))
rng2 = SeededRNG(b"Hello", b"world", ordered=(b"inquisition", b"spanish"))
rng1 == rng2  # False
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/BananaLoaf/seedrandom",
    "name": "seedrandom",
    "maintainer": "BananaLoaf",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "bananaloaf@protonmail.com",
    "keywords": "random,seed,seeded,number,generator,hash,int,float,bool,bytes,rng,deterministic",
    "author": "BananaLoaf",
    "author_email": "bananaloaf@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9f/45/05b800d1b070b1e805f71e59bcf5865178c6e58aa9d006d0539e373f45a9/seedrandom-2.3.1.tar.gz",
    "platform": null,
    "description": "# seedrandom\nDeterministic seeded RNG\n\n[![Python Version](https://img.shields.io/pypi/pyversions/seedrandom.svg?color=yellow&style=flat-square)](https://www.python.org/downloads/)\n[![GitHub Licence](https://img.shields.io/github/license/BananaLoaf/seedrandom.svg?color=blue&style=flat-square)](https://github.com/BananaLoaf/seedrandom/blob/master/LICENSE)\n[![Package Version](https://img.shields.io/pypi/v/seedrandom.svg?color=green&style=flat-square)](https://pypi.org/project/seedrandom/)\n\n\n### Installation / Updating\n```\npip install seedrandom\npip install --upgrade seedrandom\n```\nOr\n```\npip install git+https://github.com/BananaLoaf/seedrandom.git\npip install --upgrade git+https://github.com/BananaLoaf/seedrandom.git\n```\n\n### Usage\n\n```python\nfrom seedrandom import SeededRNG\nrng = SeededRNG(b\"Test\", b\"values\", hash_func=hashlib.sha512)  # any hash func from hashlib\n```\n\nGenerating random values:\n```python\nrng.randint(a=0, b=1000)  # 893\nrng.randfloat(a=0, b=100, step=0.1)  # 89.3\nrng.randbool()  # False\nrng.randbyte()  # b'\\xbf'\n```\n\n```SeededRNG``` can be converted to and from ```int``` or ```bytes```:\n```python\nbytes(rng)\nint(rng)\n\nrng1 = SeededRNG.from_bytes(b'\\xbb\\x9a\\xf3\\xe3\\x1d\\xfcA\\xcc\\xc5\\x93S\\x9a\\xec:\\x9a\\x08z\\x88\\x85\\x99\\xf7\\xea\\x91\\xb6x\\x00\\xfb\\x82\"\\xc2$K', hash_func=hashlib.blake2s)\nrng2 = SeededRNG.from_int(13391421701272821393603640485300504071883816826531413055648909144818643814535822212998295950921452703111178763035507290455800978052021014498426299707601814, hash_func=hashlib.sha512)\n```\n\n```ordered``` parameter can be used:\n```python\nrng1 = SeededRNG(b\"Hello\", b\"world\")\nrng2 = SeededRNG(b\"world\", b\"Hello\")\nrng1 == rng2  # True\n\nrng1 = SeededRNG(ordered=(b\"Hello\", b\"world\"))\nrng2 = SeededRNG(ordered=(b\"world\", b\"Hello\"))\nrng1 == rng2  # False\n\nrng1 = SeededRNG(b\"Hello\", b\"world\", ordered=(b\"spanish\", b\"inquisition\"))\nrng2 = SeededRNG(b\"world\", b\"Hello\", ordered=(b\"spanish\", b\"inquisition\"))\nrng1 == rng2  # True\n\nrng1 = SeededRNG(b\"Hello\", b\"world\", ordered=(b\"spanish\", b\"inquisition\"))\nrng2 = SeededRNG(b\"Hello\", b\"world\", ordered=(b\"inquisition\", b\"spanish\"))\nrng1 == rng2  # False\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Proof-of-concept seeded RNG lib",
    "version": "2.3.1",
    "project_urls": {
        "Homepage": "https://github.com/BananaLoaf/seedrandom",
        "Repository": "https://github.com/BananaLoaf/seedrandom"
    },
    "split_keywords": [
        "random",
        "seed",
        "seeded",
        "number",
        "generator",
        "hash",
        "int",
        "float",
        "bool",
        "bytes",
        "rng",
        "deterministic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "481e422b52d2c82116f948bbae1715661b58a218dfedac2d0dfc6c5f4da735b8",
                "md5": "3db4987465d02cb9a5bf4af6e6bc10e7",
                "sha256": "5269632b66c9d7988cd6143a9f53510cd7d9fc06c90aefe92741f68fd0d90d5f"
            },
            "downloads": -1,
            "filename": "seedrandom-2.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3db4987465d02cb9a5bf4af6e6bc10e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 4616,
            "upload_time": "2023-09-08T23:58:43",
            "upload_time_iso_8601": "2023-09-08T23:58:43.126609Z",
            "url": "https://files.pythonhosted.org/packages/48/1e/422b52d2c82116f948bbae1715661b58a218dfedac2d0dfc6c5f4da735b8/seedrandom-2.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f4505b800d1b070b1e805f71e59bcf5865178c6e58aa9d006d0539e373f45a9",
                "md5": "7acc20cccbcb6505814a485e5bda6743",
                "sha256": "a0f7ca322efe13ce4d3af28c9541b24b1945f63d5040e55479aadb45cad96696"
            },
            "downloads": -1,
            "filename": "seedrandom-2.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "7acc20cccbcb6505814a485e5bda6743",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 4638,
            "upload_time": "2023-09-08T23:58:44",
            "upload_time_iso_8601": "2023-09-08T23:58:44.604903Z",
            "url": "https://files.pythonhosted.org/packages/9f/45/05b800d1b070b1e805f71e59bcf5865178c6e58aa9d006d0539e373f45a9/seedrandom-2.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-08 23:58:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "BananaLoaf",
    "github_project": "seedrandom",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "seedrandom"
}
        
Elapsed time: 0.12818s