{"id":21134979,"url":"https://github.com/rudxain/xorsum","last_synced_at":"2026-03-08T13:31:11.124Z","repository":{"id":44375281,"uuid":"512329994","full_name":"Rudxain/xorsum","owner":"Rudxain","description":"Get XOR checksum with this command-line tool","archived":false,"fork":false,"pushed_at":"2024-07-11T17:05:46.000Z","size":1718,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T12:47:58.036Z","etag":null,"topics":["binary","checksum","cli","data","digest","file","files","hexadecimal","rust-crate","xor"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/xorsum","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rudxain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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-07-10T02:49:12.000Z","updated_at":"2024-07-11T17:05:49.000Z","dependencies_parsed_at":"2024-05-22T06:39:06.337Z","dependency_job_id":"b6d8e9ed-2073-4618-a035-88e8e80331b0","html_url":"https://github.com/Rudxain/xorsum","commit_stats":{"total_commits":259,"total_committers":2,"mean_commits":129.5,"dds":"0.0038610038610038533","last_synced_commit":"52b82561ff6579ab73261441cb39cec9b489414b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rudxain%2Fxorsum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rudxain%2Fxorsum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rudxain%2Fxorsum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rudxain%2Fxorsum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rudxain","download_url":"https://codeload.github.com/Rudxain/xorsum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241681826,"owners_count":20002383,"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","checksum","cli","data","digest","file","files","hexadecimal","rust-crate","xor"],"created_at":"2024-11-20T06:40:00.580Z","updated_at":"2026-03-08T13:31:11.118Z","avatar_url":"https://github.com/Rudxain.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xorsum\n\n## Algorithm\n\nIt uses the [XOR-cipher](https://en.wikipedia.org/wiki/XOR_cipher) to compute a [checksum](https://en.wikipedia.org/wiki/Checksum) digest. Basically, it splits the data in non-overlapping chunks (padding the remainder with `0`s), where each chunk's length equals digest size, and XORs all chunks together into an output chunk (the final digest).\n\nThis isn't a good [HF](https://en.wikipedia.org/wiki/Hash_function). It lacks the [Avalanche Effect](https://en.wikipedia.org/wiki/Avalanche_effect), because flipping 1 input bit flips 1 output bit.\n\n## Program\n\nThe raw digest size is 8octets by default, but can be set to any valid `usize` value with the `--length` option. The printed size is 16Bytes, because of ASCII hexadecimal expansion.\n\n\u003e Why 8B?\n\nThat was a _somewhat_ arbitrary decision. I've choosen 8 because it's the geometric-mean of 4 and 16, CRC32's and MD5's digest-sizes, respectively. 8B is easier to implement (in many langs) than 16B, when a constant fixed size is desired, because it fits in `u64`.\n\nThe [I.V.](https://en.wikipedia.org/wiki/Initialization_vector) is hardcoded to be 0.\n\nName and behavior heavily influenced by\n- [uu-`hashsum`](https://github.com/uutils/coreutils/tree/main/src/uu/hashsum)\n- [`cksum`](https://en.wikipedia.org/wiki/Cksum)\n- [`md5sum`](https://en.wikipedia.org/wiki/Md5sum)\n- [`BLAKE3`](https://github.com/BLAKE3-team/BLAKE3/tree/master/b3sum).\n\n## Usage\nTo install latest release from `crates.io` registry:\n```sh\ncargo install xorsum \\\n\t--config 'build.rustflags=\"-C target-cpu=native\"'\n```\nThis isn't guaranteed to be the latest version, but it'll always compile.\n\nTo install latest dev crate from GH:\n```sh\ngit clone --depth=1 https://github.com/Rudxain/xorsum \u0026\u0026 \\\ncd xorsum \u0026\u0026 \\\ncargo install --path . \\\n\t--config 'build.rustflags=\"-C target-cpu=native\"'\n```\nThis is the **most recent** (\"cutting-edge\") version. Compilation isn't guaranteed. Semver may be broken. And `--help` may not reflect actual program behavior.\n\nTo get compiled non-dev \"portable\" executables, go to [GH releases](https://github.com/Rudxain/xorsum/releases), or use [`binstall`](https://github.com/cargo-bins/cargo-binstall):\n```sh\ncargo binstall xorsum\n```\nArtifacts are only compatible with GNU-Linux x64. There are no `*.exe`s because I won't support [M$](https://consumerrights.wiki/Microsoft) or [RottenCore](https://stallman.org/apple)/[\"Apple\"](https://consumerrights.wiki/Apple).\n\nFor a Llamalab Automate implementation, visit [XOR hasher](https://llamalab.com/automate/community/flows/42903).\n\nArgument \"syntax\":\n```sh\nxorsum [OPTIONS] [FILE]...\n```\n\nFor ℹinfo about options, run:\n```sh\nxorsum --help\n```\n\n## Examples\n\n### Regular use\n\n```sh\n# let's create an empty file named \"a\"\ntouch a\nxorsum --length 4 a\n# output will be \"00000000 a\" (without quotes)\n\n# write \"aaaa\" to this file and rehash it\necho -n aaaa \u003e a\nxorsum a -l 4\n#out: \"61616161 a\"\n# because \"61\" is the hex value of the UTF-8 char \"a\"\n\n# same result when using stdin\necho -n aaaa | xorsum -l4\n#61616161 -\n\nxorsum a --brief #`-l 8` is implicit\n#6161616100000000\n```\n\n\u003e [!note]\n\u003e `echo -n` has [different behavior depending on OS and binary version](https://unix.stackexchange.com/a/65819), it might include line endings like `\\n` (LF) or `\\r\\n` (CR-LF). The outputs shown in the example are the (usually desired) result of **NOT** including an EOL.\n\n### Emulating 🏔AE\n\n`--length` **doesn't truncate** the output (unlike `b3sum`):\n\n```sh\nxorsum some_big_file -bl 3 #\"00ff55\"\nxorsum some_big_file -bl 2 #\"69aa\" NOT \"00ff\"\n```\n\nAs you can see, `-l` can return very different hashes from the same input. This property can be exploited to emulate the Avalanche Effect (to some extent).\n\n### Finding corrupted bytes\n\nIf you have 2 copies of a file and 1 is corrupted, you can attempt to [\"🔺️triangulate\"](https://en.wikipedia.org/wiki/Triangulation) the index of a corrupted byte, without manually searching the entire file. This is useful when dealing with big raw-binary files\n\n```sh\nxorsum a b\n#6c741b7863326b2c a\n#6c74187863326b2c b\n# the 0-based index is 2 when using `-l 8`\n# mathematically, i mod 8 = 2\n\nxorsum a b -l 3\n#3d5a0a a\n#3d590a b\n# i mod 3 = 1\n\nxorsum a b -l 2\n#7f12 a\n#7c12 b\n# i mod 2 = 0\n\n# you can repeat this process with different `-l` values, to solve it easier.\n# IIRC, using primes gives you more info about the index\n```\n\nThere are programs (like [`diff`](https://en.wikipedia.org/wiki/Diff)) that compare bytes for you, and are more efficient and user-friendly. But if you are into math puzzles, this is a good way to pass the time by solving [systems of linear modular equations](https://youtu.be/LInNgWMtFEs) 🤓.\n\n## 💭Thoughts\n\nI was surprised I couldn't find any implementation of a checksum algorithm completely based on `XOR`, so I posted this for the sake of completeness, and because I'm learning Rust. I also made this for low-power devices, despite only releasing for x64.\n\n## ⚠DISCLAIMER\n\n0. **DO NOT SHARE CHECKSUMS OF PRIVATE DATA.** You might be leaking sensitive information. Small sums and bigger files tend to be safer, because the `sbox` will (probably) have enough bytes to _\"mix well\"_.\n1. This program is **not production-ready**. The version should be `0.x.y` to reflect the incompleteness of the code. I'm sorry for the inconvenience and potential confusion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudxain%2Fxorsum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frudxain%2Fxorsum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudxain%2Fxorsum/lists"}