{"id":26518784,"url":"https://github.com/Racum/django-binhash","last_synced_at":"2025-03-21T10:02:18.005Z","repository":{"id":57419097,"uuid":"100279272","full_name":"Racum/django-binhash","owner":"Racum","description":"Work with hexadecimal, store in binary, using half of the data size.","archived":false,"fork":false,"pushed_at":"2024-07-09T12:31:07.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-25T04:33:44.975Z","etag":null,"topics":["binary-data","data-structures","django","django-orm","fieldtype","hash"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Racum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-14T14:55:21.000Z","updated_at":"2024-07-09T12:31:51.000Z","dependencies_parsed_at":"2022-09-20T22:45:39.075Z","dependency_job_id":null,"html_url":"https://github.com/Racum/django-binhash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Racum%2Fdjango-binhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Racum%2Fdjango-binhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Racum%2Fdjango-binhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Racum%2Fdjango-binhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Racum","download_url":"https://codeload.github.com/Racum/django-binhash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244776323,"owners_count":20508506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-data","data-structures","django","django-orm","fieldtype","hash"],"created_at":"2025-03-21T10:02:17.341Z","updated_at":"2025-03-21T10:02:17.939Z","avatar_url":"https://github.com/Racum.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Django Binary Hash Fields\n\nWork with hexadecimal, store in binary, using half of the data size.\n\n## Installation\n\nJust install via `pip`:\n\n```\npip install django-binhash\n```\n\nAnd add to your apps on `settings.py`:\n\n```python\nINSTALLED_APPS = [\n    # Django apps\n    'binhash',\n    # Your apps\n]\n```\n## Compatibility\n\n### Environments\n\nTested under Python from 3.10 to 3.12, and under Django 4.x and 5.x.\n\n### Databases\n\nAt the version `0.2.0` it was only tested on SQLite, but if should work fine in all databases officially supported by Django.\n\n### Formats\n\n* MD5\n\t* `MD5Field`\n* SHA-1\n\t* `SHA1Field`\n* SHA-2\n\t* `SHA224Field`\n\t* `SHA256Field`\n\t* `SHA384Field`\n\t* `SHA512Field`\n* SHA-3\n\t* `SHA3_224Field`\n\t* `SHA3_256Field`\n\t* `SHA3_384Field`\n\t* `SHA3_512Field`\n\t* `SHAKE128Field`\n\t* `SHAKE256Field`\n\t* `SHAKE512Field`\n\n## Usage\n\nJust import and set some fields:\n\n```python\nfrom django.db import models\nfrom binhash import (MD5Field, SHA1Field, SHA256Field)\n\nclass ISOFile(models.Model):\n    name = models.CharField('Name', max_length=30)\n    url = models.URLField('URL')\n    md5sum = MD5Field('MD5 Checksum')\n    sha1sum = SHA1Field('SHA-1 Checksum')\n    sha256sum = SHA256Field('SHA-256 Checksum')\n```\n\nThan, proceed using them like CharFields:\n\n```python\n# Create normaly as if the fields were strings:\nISOFile.objects.create(\n    name='Ubuntu Server 17.04',\n    md5sum='d02df11b4a7318b7250824f6d0bab9c0',\n    sha1sum='bc5fb639724b5cd90eb739845f246e2c564b0dd8',\n    sha256sum='632e64dde9a7da27fa96bea4d2cf78f051065c6becc0d0f728aabfc091396256',\n)\n\n# Fetch by string is also supported:\nubuntu = ISOFile.objects.get(md5sum='d02df11b4a7318b7250824f6d0bab9c0')\n\n# Everything works as expected on the application side:\nprint(ubuntu.sha1sum)  # Shows bc5fb639724b5cd90eb739845f246e2c564b0dd8\nprint(type(ubuntu.sha1sum))  # Shows \u003cclass 'str'\u003e\n\n```\n\nIf you are feeling skeptical, check the database:\n\n```\n$ ./manage.py dbshell\nsqlite\u003e .header on\nsqlite\u003e .mode column\nsqlite\u003e select hex(sha1sum) hex_sha1,\n   ...\u003e        length(hex(sha1sum)) size_if_this_was_varchar,\n   ...\u003e        length(sha1sum) actual_size\n   ...\u003e from downloads_isofile;\nhex_sha1                                  size_if_this_was_varchar  actual_size\n----------------------------------------  ------------------------  -----------\nBC5FB639724B5CD90EB739845F246E2C564B0DD8  40                        20\n\n```\n\n## License\n\nThis library is released under the **3-Clause BSD License**.\n\n**tl;dr**: *\"free to use as long as you credit me\"*.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRacum%2Fdjango-binhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRacum%2Fdjango-binhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRacum%2Fdjango-binhash/lists"}