{ "info": { "author": "Leonides T. Saguisag Jr.", "author_email": "leonidessaguisagjr@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "``filehash``\n============\n\nPython module to facilitate calculating the checksum or hash of a file. Tested against Python 2.7, Python 3.6, PyPy 2.7 and PyPy 3.5. Currently supports `Adler-32 `_, `CRC32 `_, `MD5 `_, `SHA-1 `_, `SHA-256 and SHA-512 `_.\n\n``FileHash`` class\n------------------\n\nThe ``FileHash`` class wraps around the ``hashlib`` (provides hashing for MD5, SHA-1, SHA-256 and SHA-512) and ``zlib`` (provides checksums for Adler-32 and CRC32) modules and contains the following methods:\n\n- ``hash_file(filename)`` - Calculate the file hash for a single file. Returns a string with the hex digest.\n- ``hash_dir(path, pattern='*')`` - Calculate the file hashes for an entire directory. Returns a list of tuples where each tuple contains the filename and the calculated hash.\n- ``verify_sfv(sfv_filename)`` - Reads the specified SFV (Simple File Verification) file and calculates the CRC32 checksum for the files listed, comparing the calculated CRC32 checksums against the specified expected checksums. Returns a list of tuples where each tuple contains the filename and a boolean value indicating if the calculated CRC32 checksum matches the expected CRC32 checksum. To find out more about SFV files, see the `Simple file verification entry in Wikipedia `_.\n- ``verify_checksums(checksum_filename)`` - Reads the specified file and calculates the hashes for the files listed, comparing the calculated hashes against the specified expected hashes. Returns a list of tuples where each tuple contains the filename and a boolean value indicating if the calculated hash matches the expected hash.\n\nFor the checksum file, the file is expected to be a plain text file where each line has an entry formatted as follows::\n\n {hash}[SPACE][ASTERISK]{filename}\n\nThis format is the format used by programs such as the `sha1sum `_ family of tools for generating checksum files. Here is an example generated by ``sha1sum``::\n\n f7ef3b7afaf1518032da1b832436ef3bbfd4e6f0 *lorem_ipsum.txt\n 03da86258449317e8834a54cf8c4d5b41e7c7128 *lorem_ipsum.zip\n\nThe ``FileHash`` constructor has two optional arguments:\n\n- ``hash_algorithm='sha256'`` - Specifies the hashing algorithm to use. See ``filehash.SUPPORTED_ALGORITHMS`` for the list of supported hash / checksum algorithms. Defaults to SHA256.\n- ``chunk_size=4096`` - Integer specifying the chunk size to use (in bytes) when reading the file. This comes in useful when processing very large files to avoid having to read the entire file into memory all at once. Default chunk size is 4096 bytes.\n\nExample usage\n-------------\n\nThe library can be used as follows::\n\n >>> import os\n >>> from filehash import FileHash\n >>> md5hasher = FileHash('md5')\n >>> md5hasher.hash_file(\"./testdata/lorem_ipsum.txt\")\n '72f5d9e3a5fa2f2e591487ae02489388'\n >>> sha1hasher = FileHash('sha1')\n >>> sha1hasher.hash_dir(\"./testdata\", \"*.zip\")\n [FileHashResult(filename='lorem_ipsum.zip', hash='03da86258449317e8834a54cf8c4d5b41e7c7128')]\n >>> sha512hasher = FileHash('sha512')\n >>> os.chdir(\"./testdata\")\n >>> sha512hasher.verify_checksums(\"./hashes.sha512\")\n [VerifyHashResult(filename='lorem_ipsum.txt', hashes_match=True), VerifyHashResult(filename='lorem_ipsum.zip', hashes_match=True)]\n >>> crc32hasher = FileHash('crc32')\n >>> crc32hasher.verify_sfv(\"./lorem_ipsum.sfv\")\n [VerifyHashResult(filename='lorem_ipsum.txt', hashes_match=True), VerifyHashResult(filename='lorem_ipsum.zip', hashes_match=True)]\n\n\n``chkfilehash`` command line tool\n---------------------------------\n\nA command-line tool called ``chkfilehash`` is also included with the ``filehash`` package. Here is an example of how the tool can be used::\n\n $ chkfilehash -a sha512 -c hashes.sha512\n lorem_ipsum.txt: OK\n lorem_ipsum.zip: OK\n $ chkfilehash -a crc32 lorem_ipsum.zip\n 7425D3BE *lorem_ipsum.zip\n $\n\nRun the tool without any parameters or with the ``-h`` / ``--help`` switch to get a usage screen.\n\nLicense\n-------\n\nThis is released under an MIT license. See the ``LICENSE`` file in this repository for more information.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/leonidessaguisagjr/filehash", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "filehash", "package_url": "https://pypi.org/project/filehash/", "platform": "", "project_url": "https://pypi.org/project/filehash/", "project_urls": { "Homepage": "https://github.com/leonidessaguisagjr/filehash" }, "release_url": "https://pypi.org/project/filehash/0.1.dev3/", "requires_dist": null, "requires_python": "", "summary": "Module and command-line tool that wraps around hashlib and zlib to facilitate generating checksums / hashes of files and directories.", "version": "0.1.dev3" }, "last_serial": 3842823, "releases": { "0.1.dev0": [ { "comment_text": "", "digests": { "md5": "4a30fd5f9a48bcdea5c32efe05a8051d", "sha256": "a58a3ed99633ba9ef871ab064033c861e7de342e437230e3aade6e7370008096" }, "downloads": -1, "filename": "filehash-0.1.dev0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4a30fd5f9a48bcdea5c32efe05a8051d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6147, "upload_time": "2018-05-06T09:15:35", "url": "https://files.pythonhosted.org/packages/0c/2a/d4a3b36b45899160064883331a85a4f5af99ac1f70508d4dde4026711b73/filehash-0.1.dev0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d55cb1ea0c85dea4c58ab03a351cac89", "sha256": "0839d7caeb7186b18bfbe59af3a2d2ff948d9fb826c72f0f200f98a71d424f65" }, "downloads": -1, "filename": "filehash-0.1.dev0.tar.gz", "has_sig": false, "md5_digest": "d55cb1ea0c85dea4c58ab03a351cac89", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4385, "upload_time": "2018-05-06T09:15:36", "url": "https://files.pythonhosted.org/packages/aa/aa/1bfc41c7430ac8641e2d8fbb9c8139520a37c23e279dd17b9f71da70099b/filehash-0.1.dev0.tar.gz" } ], "0.1.dev1": [ { "comment_text": "", "digests": { "md5": "3eb608a6b3c70a8f83ab1f939969954f", "sha256": "27e73a5bd6378256ce01a2f94477fe7c145a808f1c7417a0bc7738c11b41b7e5" }, "downloads": -1, "filename": "filehash-0.1.dev1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3eb608a6b3c70a8f83ab1f939969954f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7503, "upload_time": "2018-05-07T04:33:13", "url": "https://files.pythonhosted.org/packages/4d/c8/de87d70778ed93aa67c8c3a509edaaf48187133468f946e92a0f5df388f2/filehash-0.1.dev1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b4a7346c19267e90a1935dfd82e6efa8", "sha256": "d2ac4480456d22aa462a2c74627fbe23a255e802b1a2ef9dfebf618c863093f0" }, "downloads": -1, "filename": "filehash-0.1.dev1.tar.gz", "has_sig": false, "md5_digest": "b4a7346c19267e90a1935dfd82e6efa8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5479, "upload_time": "2018-05-07T04:33:14", "url": "https://files.pythonhosted.org/packages/69/1c/9d683d99545b7ce3aafa19405ed873aa180445e2561c50c48a72af1438ad/filehash-0.1.dev1.tar.gz" } ], "0.1.dev2": [ { "comment_text": "", "digests": { "md5": "aa73cd49fef86d04ecc5d22fd60da97b", "sha256": "378e5e89c026c3b02b5daa134251a0925fc5bcdbb76f3e207ea1b8c1d22dbbf3" }, "downloads": -1, "filename": "filehash-0.1.dev2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "aa73cd49fef86d04ecc5d22fd60da97b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8003, "upload_time": "2018-05-07T07:07:02", "url": "https://files.pythonhosted.org/packages/86/1f/c264ab2ea1a0d6fc272d7927753b0c3a7576ae551b139e9c846cad93a29d/filehash-0.1.dev2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7d3bbe6e707d2b665aae927da824889a", "sha256": "d05e66f61ed3465dc9bf14475c486e302962202a0151c97747bcd66cafdbddbd" }, "downloads": -1, "filename": "filehash-0.1.dev2.tar.gz", "has_sig": false, "md5_digest": "7d3bbe6e707d2b665aae927da824889a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5839, "upload_time": "2018-05-07T07:07:03", "url": "https://files.pythonhosted.org/packages/c3/25/90c04b1d6340af2eb3529e9b4e6843262fd59ac8213daec69fd549df917e/filehash-0.1.dev2.tar.gz" } ], "0.1.dev3": [ { "comment_text": "", "digests": { "md5": "467512aea0fef5a9b1b5d4f26a825687", "sha256": "a119cf95aecf8061c183a86849c59a8790f536960941eb989564a9ceade05d5c" }, "downloads": -1, "filename": "filehash-0.1.dev3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "467512aea0fef5a9b1b5d4f26a825687", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9774, "upload_time": "2018-05-08T02:02:53", "url": "https://files.pythonhosted.org/packages/2e/8f/f13290692fecd3583af19a2a997facbb91729a6c6494d722c2f08ef73fce/filehash-0.1.dev3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "68f053c8a265c88559a5300bf5922edb", "sha256": "0a0c5741006bce9cc9552dfa100d6ca5e9c95d4aadefec0b1f44e6e5fa5e7fed" }, "downloads": -1, "filename": "filehash-0.1.dev3.tar.gz", "has_sig": false, "md5_digest": "68f053c8a265c88559a5300bf5922edb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7904, "upload_time": "2018-05-08T02:02:54", "url": "https://files.pythonhosted.org/packages/67/96/ba72a57f5c564f15c62a0eb1df55b60bbfea0d3f63e90b6460835104d787/filehash-0.1.dev3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "467512aea0fef5a9b1b5d4f26a825687", "sha256": "a119cf95aecf8061c183a86849c59a8790f536960941eb989564a9ceade05d5c" }, "downloads": -1, "filename": "filehash-0.1.dev3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "467512aea0fef5a9b1b5d4f26a825687", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9774, "upload_time": "2018-05-08T02:02:53", "url": "https://files.pythonhosted.org/packages/2e/8f/f13290692fecd3583af19a2a997facbb91729a6c6494d722c2f08ef73fce/filehash-0.1.dev3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "68f053c8a265c88559a5300bf5922edb", "sha256": "0a0c5741006bce9cc9552dfa100d6ca5e9c95d4aadefec0b1f44e6e5fa5e7fed" }, "downloads": -1, "filename": "filehash-0.1.dev3.tar.gz", "has_sig": false, "md5_digest": "68f053c8a265c88559a5300bf5922edb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7904, "upload_time": "2018-05-08T02:02:54", "url": "https://files.pythonhosted.org/packages/67/96/ba72a57f5c564f15c62a0eb1df55b60bbfea0d3f63e90b6460835104d787/filehash-0.1.dev3.tar.gz" } ] }