{"id":21142696,"url":"https://github.com/antoniopelusi/ca-hash","last_synced_at":"2025-10-26T17:04:15.781Z","repository":{"id":156265363,"uuid":"631383826","full_name":"antoniopelusi/CA-hash","owner":"antoniopelusi","description":"Hash function based on the non-reversible Cellular Automata Game of Life.","archived":false,"fork":false,"pushed_at":"2023-07-09T11:53:52.000Z","size":76,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T16:49:42.709Z","etag":null,"topics":["game-of-life","gameoflife","hash","hash-function"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antoniopelusi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-22T21:16:31.000Z","updated_at":"2025-02-07T08:27:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"516d7480-fac7-4f8f-b55b-e76501e950ae","html_url":"https://github.com/antoniopelusi/CA-hash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/antoniopelusi/CA-hash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniopelusi%2FCA-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniopelusi%2FCA-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniopelusi%2FCA-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniopelusi%2FCA-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antoniopelusi","download_url":"https://codeload.github.com/antoniopelusi/CA-hash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniopelusi%2FCA-hash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281139041,"owners_count":26450141,"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","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["game-of-life","gameoflife","hash","hash-function"],"created_at":"2024-11-20T07:59:28.579Z","updated_at":"2025-10-26T17:04:15.747Z","avatar_url":"https://github.com/antoniopelusi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CA-hash 🛡️\n**Experimental hash function** based on the non-reversible **C**ellular **A**utomata [*Game of Life*](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)\n\nImplementation of Game Of Life [here](https://github.com/antoniopelusi/game-of-life-CLI)!\n\n## Parameters\n\n- **hash_length**: the length of the final hash (*default: ```512```*), if ```0```: get the full size hash\n\n- **iter**: number of the Game of Life iterations applied to the initial grid (*default: ```5```*)\n\n- **grid_size**: size of the grid used to apply Game of Life iterations (*default: ```128```*)\n\n- **print_grid**: if *```True```*: print the initial grid and final grid to terminal (*default: ```False```*)\n\n## Usage information\n\n- this hash function do not use any external library apart from *numpy* for the generation of the random grid\n\n- the Game of Life is non-reversible (there are multiple \npre-configurations for every grid configuration)\n\n- change the **mode** variable to switch from the two modes:\n\n    - *hash mode*: generate the hash text\n    \n    - *bias_test mode*: test the bias of the hexadecimal values of the hash (is possible to change the *n_iteration* variable to test more hashes in a row)\n\n## Steps\n\n1. generate the key converting the input string into a list of the input characters econded in *utf-8*\n\n1. create the random grid using the key as seed\n\n1. execute the non-reversible Game of Life iterations on the grid\n\n1. linearize the matrix in a string of bits\n\n1. remove any string of 5 consecutive zeros (```00000```) string from the string of bits to decrease the ```0```/```1``` bias\n\n1. shuffle the string of bits\n\n1. convert groups of 4 binary bits into hexadecimal values\n\n1. shuffle the string of hexadecimal values\n\n1. trim the string of hexadecimal values to the desired size\n\n1. return the final hash\n\n## Tests\n\nThe **CA-hash** function has some bias, caused by the bias in ```0```'s and ```1```'s in Game Of Life.\n\nTo decrease this bias, every string of 5 consecutive zeros (```00000```) will be removed from the linearized matrix.\n\n\u003e**Input:** ```\"test\"```\n\u003e\n\u003e**Hash length:** ```512```\n\u003e\n\u003e**Number of Game Of Life iterations:** ```5```\n\u003e\n\u003e**Grid size:** ```128```\n\u003e\n\u003e![](tests/test_512.png)\n\n\u003e**Input:** ```\"test\"```\n\u003e\n\u003e**Hash length:** ```1024```\n\u003e\n\u003e**Number of Game Of Life iterations:** ```5```\n\u003e\n\u003e**Grid size:** ```128```\n\u003e\n\u003e![](tests/test_1024.png)\n\n\u003e**Input:** ```Numerical range from 0 to 99```\n\u003e\n\u003e**Hash length:** ```512```\n\u003e\n\u003e**Number of Game Of Life iterations:** ```5```\n\u003e\n\u003e**Grid size:** ```128```\n\u003e\n\u003e![](tests/x100_512.png)\n\n\u003e**Input:** ```Numerical range from 0 to 99```\n\u003e\n\u003e**Hash length:** ```1024```\n\u003e\n\u003e**Number of Game Of Life iterations:** ```5```\n\u003e\n\u003e**Grid size:** ```128```\n\u003e\n\u003e![](tests/x100_1024.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniopelusi%2Fca-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoniopelusi%2Fca-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniopelusi%2Fca-hash/lists"}