{ "info": { "author": "William James", "author_email": "jameswt@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "RandomIO\n===============\n\n[![Build Status](https://travis-ci.org/Storj/RandomIO.svg)](https://travis-ci.org/Storj/RandomIO) [![Coverage Status](https://img.shields.io/coveralls/Storj/RandomIO.svg)](https://coveralls.io/r/Storj/RandomIO?branch=master)\n\n`RandomIO` provides a readable interface for cryptographic quality random bytes. It also allows for generation of random files, dumping random bytes to files, and a `.read()` method for reading bytes.\n\n### Installation\n\n```\ngit clone https://github.com/storj/RandomIO\ncd RandomIO\npip install .\n```\n\n### File generation\n\nGenerate a 50 byte file from a seed with one line:\n\n```python\nimport RandomIO\n\npath = RandomIO.RandomIO('seed string').genfile(50)\nwith open(path,'rb') as f:\n\tprint(f.read())\n\n# b\"\\xec\\xf4C\\xeb\\x1d\\rU%\\xca\\xae\\xa4^=*in\\x90y\\x12\\x86\\xce\\xe5N\\xce-\\x16\n# \\xc8r\\x83sh\\xdfp\\xb7\\xbb\\xc2\\x04\\x11\\xda)\\xc1*_\\x01\\xe5\\xd8\\x0f}N0\"\n```\n\nIt is possible to specify the directory to generate the file in, or the file name:\n\n```python\n# specify a directory:\n\npath = RandomIO.RandomIO('seed string').genfile(100,'dir/')\nprint(path)\n\n# 'dir/22aae6183b5202cd0c74381c673394d2'\n\n# or file name:\n\npath = RandomIO.RandomIO('seed string').genfile(100,'dir/file')\nprint(path)\n\n# 'dir/file'\n```\n\n### Byte generation\n\nIt is possible to read random bytes and dump those bytes to a file object:\n\n```python\nimport RandomIO\n\ns = RandomIO.RandomIO()\nprint(s.read(10))\n\n# b'\\x8bfT\\x9c\\x06_)\\xa2,\\xd0'\n\n# or generate seeded random bytes\ns = RandomIO.RandomIO('seed string')\nprint(s.read(10))\n\n# b'\\xec\\xf4C\\xeb\\x1d\\rU%\\xca\\xae'\n\n# dump the bytes into a file object\ns = RandomIO.RandomIO('seed string')\nwith open('path/to/file','wb') as f:\n\ts.dump(10,f)\n\nwith open('path/to/file','rb') as f:\n\tprint(f.read())\n\t\n# b'\\xec\\xf4C\\xeb\\x1d\\rU%\\xca\\xae'\n```\n\n### CLI Tools\n\nRandomIO includes a small set of CLI tools in IOTools.py:\n\n```\n$python IOTools.py --help\nusage: IOTools.py []\n\nCurrently available commands include:\n pairgen Outputs a series of seed-hash pairs for files generated using the RandomIO library.\n\nA series of command-line tools that make use of the RandomIO library.\n\npositional arguments:\n command Command to run.\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\nCurrently, `pairgen` is the only available tool:\n\n```\n$ IOTools.py pairgen --help\nusage: IOTools.py [-h] [-l LENGTH] [-p PAIRS] [-o OUTPUT] [-v] size\n\nOutput a series of seed-hash pairs for files generated in memory using the\nRandomIO library.\n\npositional arguments:\n size The target size of each file generated and hashed (in\n bytes).\n\noptional arguments:\n -h, --help show this help message and exit\n -l LENGTH, --length LENGTH\n The length of the random seed string to use.\n -p PAIRS, --pairs PAIRS\n The number of seed-hash pairs to generate.\n -o OUTPUT, --output OUTPUT\n The name of the file you wish to write pairs to.\n -r, --redis Write to file using Redis protocol.\n -v, --verbose Increase output verbosity.\n\nThis tool can be used to pre-generate seed-hash pairs for the Storj uptick\nservice.\n```\n\nExample output of `pairgens`:\n\n```\n$ IOTools.py pairgen 100000000 -p5 -l 10 -o mypairs.txt -v\nPair 0: Generating hash for 95.4MB file with seed 6a95c93fa9ca92d249d2...\ndone!\nPair 1: Generating hash for 95.4MB file with seed 7b31909908ff413061ce...\ndone!\nPair 2: Generating hash for 95.4MB file with seed a440bcd97af94701282c...\ndone!\nPair 3: Generating hash for 95.4MB file with seed 0f1f9dad1d6da7e03367...\ndone!\nPair 4: Generating hash for 95.4MB file with seed f146dbbe9c1706e1c3d6...\ndone!\n```\n\nNote that files are generated and hashed in memory. In addition, seeds displayed and/or written to file are hex-encoded. Actual seeds must be decoded before generating hash.\n\nWhen writing pairs to file using Redis's mass insertion format, you can use the following command to import your pairs to Redis:\n\n`cat pairs.out | redis-cli --pipe`\n\n### Performance\n\n```\n> python -m timeit -p -s 'import RandomIO, os' 'path=RandomIO.RandomIO().genfile(100000000);os.remove(path)'\n10 loops, best of 3: 1.4 sec per loop\n```\n\nFrom a simple timeit analysis on a 2.4 GHz PC it can generate files at around 70 MB/s.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/storj/RandomIO/tarball/0.2.1", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Storj/RandomIO", "keywords": "storj,randomIO,random generator", "license": "The MIT License (MIT)\n\nCopyright (c) 2014 William T. James for Storj Labs\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "RandomIO", "package_url": "https://pypi.org/project/RandomIO/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/RandomIO/", "project_urls": { "Download": "https://github.com/storj/RandomIO/tarball/0.2.1", "Homepage": "https://github.com/Storj/RandomIO" }, "release_url": "https://pypi.org/project/RandomIO/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Random file and byte string generator.", "version": "0.2.1" }, "last_serial": 1563960, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "033babdbdec4849dbcd0b21a0d830b90", "sha256": "d89830409e9a2491e7930377a1b341245a590370c50a0284c1e271cc42126d8d" }, "downloads": -1, "filename": "RandomIO-0.2.0.tar.gz", "has_sig": false, "md5_digest": "033babdbdec4849dbcd0b21a0d830b90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6838, "upload_time": "2015-02-11T02:05:13", "url": "https://files.pythonhosted.org/packages/e8/6e/123dc56995e6af833c615beb738f93de53ace67d374968cf585a773647ce/RandomIO-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "ad82eae3e107b467f6b7be9bf7f91db5", "sha256": "41ed436dd1f6eecddf92c5e4963bae1abff38376b9f06d42fcdf1732e9b4c46b" }, "downloads": -1, "filename": "RandomIO-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ad82eae3e107b467f6b7be9bf7f91db5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7347, "upload_time": "2015-02-11T02:24:28", "url": "https://files.pythonhosted.org/packages/2f/4a/1d60b038821da9def8b717caa410ee9e79c864da031e0fabe65eb0395537/RandomIO-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ad82eae3e107b467f6b7be9bf7f91db5", "sha256": "41ed436dd1f6eecddf92c5e4963bae1abff38376b9f06d42fcdf1732e9b4c46b" }, "downloads": -1, "filename": "RandomIO-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ad82eae3e107b467f6b7be9bf7f91db5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7347, "upload_time": "2015-02-11T02:24:28", "url": "https://files.pythonhosted.org/packages/2f/4a/1d60b038821da9def8b717caa410ee9e79c864da031e0fabe65eb0395537/RandomIO-0.2.1.tar.gz" } ] }