{ "info": { "author": "Takeshi Kubo", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development" ], "description": "Consistent message digest for JSON object\n=====\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Maintainability](https://api.codeclimate.com/v1/badges/c89648224f4636fa8529/maintainability)](https://codeclimate.com/github/quvox/json-digest/maintainability)\n[![CircleCI](https://circleci.com/gh/quvox/json-digest/tree/develop.svg?style=shield)](https://circleci.com/gh/quvox/json-digest/tree/develop)\n\nThis module is a python module that creates structured digests based on a given JSON data for consistent message digest calculation. The procedure of digest calculation is described below.\n\nThis repository also includes [Javascript version](https://github.com/quvox/json-digest/blob/develop/javascript/README.md).\n\n\n## Environment and install\n* version\n - 3.5 or later\n* install the module\n```bash\npip install json-structure-digest\n```\n* command line tool\n - json_digest.py\n\n## Usage\n\nA basic usage is like as follows:\n```python\nimport json\nfrom jsondigest import digest\n\nobj = {\n \"digest_version\": 1,\n \"key1\": 1,\n \"key2\": 2.34,\n \"key3\": \"VALUE3\",\n \"key4\": {\n \"key4-1\": 2,\n \"key4-2\": [1, 2, 3, False, \"xyz\"]\n },\n \"key5\": [\"VALUE5\", 5.55, True, [\"VALUE5-2\", None], {\"key5-2\": 123}]\n}\njson_string = json.dumps(obj)\n\nresult = digest(json_string)\nsha256_hex = result[\"digest\"]\ndigest_structure = result[\"digest_structure\"]\n```\n\nIn the case that you have the above *digest_structure* and partial object, you can also calculate the digest using these two information and will obtain the same result as above.\n\n```python\nobj_partial = {\n \"digest_version\": 1,\n \"key1\": 1,\n \"key2\": 2.34,\n \"key3\": \"VALUE3\",\n}\njson_string_partial = json.dumps(obj_partial)\n\nresult2 = digest(json_string_partial, digest_structure=json.dumps(digest_structure))\nsha256_hex2 = result2[\"digest\"]\ndigest_structure2 = result2[\"digest_structure\"]\n```\n\nsha256_hex and sha256_hex2, digest_structure and digest_structure2 are identical, respectively. Note that the digest method accepts string params only. \n\n\n## Command line tool\n\n```json_digest.py``` is available after pip install. The usage is very simple.\n```bash\n$ json_digest.py -j path_to_jsonfile\n```\nor\n```bash\n$ cat path_to_jsonfile | json_digest.py\n```\nYou will get a json string of the digest and the digest structure of the given json file. \n\n\n\n## Requirements\n* JSON string must comply with [RFC8259](https://tools.ietf.org/html/rfc8259).\n - The JSON string must be encoded with UTF-8 and no BOM.\n - Supported types of value are string, number (integer, float), object, array, boolean and null. \n* \"digest_version\" must be included in the JSON.\n\n\n\n## Spec of version 1\n### Summary\n* ```digest_version: 1```\n* A digest is calculated for each value in a JSON object.\n* The digest function in this version is SHA256.\n* To achieve consistency, the keys at each level in the JSON object are sorted in increasing order of the ASCII value in the digest calculation procedure.\n* The following conversions before digest calculation are performed:\n - An integer value is converted in 8-byte array in little-endian. \n - A float value is converted in 8-byte array in little-endian.\n - A boolean value is converted to either \"true\" or \"false\".\n - A null value is converted to \"null\".\n* All digests are expressed in HEX string in little endian.\n\n\n\nSee [here](https://github.com/quvox/json-digest/blob/develop/README.md) in detail.\n\n\n## License\nMIT\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "json-structure-digest", "package_url": "https://pypi.org/project/json-structure-digest/", "platform": "", "project_url": "https://pypi.org/project/json-structure-digest/", "project_urls": null, "release_url": "https://pypi.org/project/json-structure-digest/0.9.1/", "requires_dist": null, "requires_python": "", "summary": "A library and tool for calculating consistent digest of a json data string", "version": "0.9.1" }, "last_serial": 5716565, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "1ccd28cf6305e7ed284e32b6fb4fde36", "sha256": "748b2bdcfdf7b67437242de70a880da4fbdba7866316024bc111b25a849c24af" }, "downloads": -1, "filename": "json-structure-digest-0.9.0.tar.gz", "has_sig": false, "md5_digest": "1ccd28cf6305e7ed284e32b6fb4fde36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15073677, "upload_time": "2019-08-15T13:59:50", "url": "https://files.pythonhosted.org/packages/e0/00/58261490e4bec59571f17c6b2a187ad7e4497eb180996b979c20375c92c7/json-structure-digest-0.9.0.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "ed1cbd50a8d0bda1ab705f728ba7bab8", "sha256": "646ebd519afd6213b00f7c52c38e59661efe18f4152fc8c592ec9e05de34fa00" }, "downloads": -1, "filename": "json_structure_digest-0.9.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ed1cbd50a8d0bda1ab705f728ba7bab8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7862, "upload_time": "2019-08-22T18:25:24", "url": "https://files.pythonhosted.org/packages/a1/d2/9b0eb56b02def2a5c2aa152eaf1fd983e97ac2fb613789c5947ee973ae99/json_structure_digest-0.9.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aa02d0bbb29eb68bf0572d8ffd1e1e1a", "sha256": "675e62b842353b9e4bf0ff187f891a949e6e12e466a8979ee07b835a0858f7f8" }, "downloads": -1, "filename": "json-structure-digest-0.9.1.tar.gz", "has_sig": false, "md5_digest": "aa02d0bbb29eb68bf0572d8ffd1e1e1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14571713, "upload_time": "2019-08-22T18:25:27", "url": "https://files.pythonhosted.org/packages/21/00/a244fa23930201d20f0151affd6c5f25912f04c02d4b91965800994055c0/json-structure-digest-0.9.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ed1cbd50a8d0bda1ab705f728ba7bab8", "sha256": "646ebd519afd6213b00f7c52c38e59661efe18f4152fc8c592ec9e05de34fa00" }, "downloads": -1, "filename": "json_structure_digest-0.9.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ed1cbd50a8d0bda1ab705f728ba7bab8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7862, "upload_time": "2019-08-22T18:25:24", "url": "https://files.pythonhosted.org/packages/a1/d2/9b0eb56b02def2a5c2aa152eaf1fd983e97ac2fb613789c5947ee973ae99/json_structure_digest-0.9.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aa02d0bbb29eb68bf0572d8ffd1e1e1a", "sha256": "675e62b842353b9e4bf0ff187f891a949e6e12e466a8979ee07b835a0858f7f8" }, "downloads": -1, "filename": "json-structure-digest-0.9.1.tar.gz", "has_sig": false, "md5_digest": "aa02d0bbb29eb68bf0572d8ffd1e1e1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14571713, "upload_time": "2019-08-22T18:25:27", "url": "https://files.pythonhosted.org/packages/21/00/a244fa23930201d20f0151affd6c5f25912f04c02d4b91965800994055c0/json-structure-digest-0.9.1.tar.gz" } ] }