{"id":16906927,"url":"https://github.com/pjbgf/sha1cd","last_synced_at":"2025-04-07T12:05:25.697Z","repository":{"id":64001379,"uuid":"569421799","full_name":"pjbgf/sha1cd","owner":"pjbgf","description":"SHA1 implementation with collision detection.","archived":false,"fork":false,"pushed_at":"2024-11-25T11:53:42.000Z","size":3523,"stargazers_count":6,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-06T20:58:37.091Z","etag":null,"topics":["collision-avoidance","collision-detection","go","sha1"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pjbgf.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":"2022-11-22T19:42:01.000Z","updated_at":"2024-11-25T11:53:45.000Z","dependencies_parsed_at":"2024-02-01T00:29:59.373Z","dependency_job_id":"faa0c1e6-9e43-460e-99c1-2bd637a6a5cf","html_url":"https://github.com/pjbgf/sha1cd","commit_stats":{"total_commits":56,"total_committers":3,"mean_commits":"18.666666666666668","dds":0.4464285714285714,"last_synced_commit":"3f2e66d410b381d7f1ac1f5b0e7da8b92b530fb7"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjbgf%2Fsha1cd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjbgf%2Fsha1cd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjbgf%2Fsha1cd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjbgf%2Fsha1cd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pjbgf","download_url":"https://codeload.github.com/pjbgf/sha1cd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648976,"owners_count":20972945,"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":["collision-avoidance","collision-detection","go","sha1"],"created_at":"2024-10-13T18:45:17.454Z","updated_at":"2025-04-07T12:05:25.677Z","avatar_url":"https://github.com/pjbgf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sha1cd\n\nA Go implementation of SHA1 with counter-cryptanalysis, which detects\ncollision attacks. \n\nThe `cgo/lib` code is a carbon copy of the [original code], based on\nthe award winning [white paper] by Marc Stevens.\n\nThe Go implementation is largely based off Go's generic sha1.\nAt present no SIMD optimisations have been implemented.\n\n## Usage\n\n`sha1cd` can be used as a drop-in replacement for `crypto/sha1`:\n\n```golang\nimport \"github.com/pjbgf/sha1cd\"\n\nfunc test(){\n\tdata := []byte(\"data to be sha1 hashed\")\n\th := sha1cd.Sum(data)\n\tfmt.Printf(\"hash: %q\\n\", hex.EncodeToString(h))\n}\n```\n\nTo obtain information as to whether a collision was found, use the\nfunc `CollisionResistantSum`.\n\n```golang\nimport \"github.com/pjbgf/sha1cd\"\n\nfunc test(){\n\tdata := []byte(\"data to be sha1 hashed\")\n\th, col  := sha1cd.CollisionResistantSum(data)\n\tif col {\n\t\tfmt.Println(\"collision found!\")\n\t}\n\tfmt.Printf(\"hash: %q\", hex.EncodeToString(h))\n}\n```\n\nNote that the algorithm will automatically avoid collision, by \nextending the SHA1 to 240-steps, instead of 80 when a collision\nattempt is detected. Therefore, inputs that contains the unavoidable\nbit conditions will yield a different hash from `sha1cd`, when compared\nwith results using `crypto/sha1`. Valid inputs will have matching the outputs.\n\n## References\n- https://shattered.io/\n- https://github.com/cr-marcstevens/sha1collisiondetection\n- https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Secure-Hashing#shavs\n\n## Use of the Original Implementation\n- https://github.com/git/git/commit/28dc98e343ca4eb370a29ceec4c19beac9b5c01e\n- https://github.com/libgit2/libgit2/pull/4136\n\n[original code]: https://github.com/cr-marcstevens/sha1collisiondetection\n[white paper]: https://marc-stevens.nl/research/papers/C13-S.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjbgf%2Fsha1cd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpjbgf%2Fsha1cd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjbgf%2Fsha1cd/lists"}