{"id":13815575,"url":"https://github.com/tkaitchuck/aHash","last_synced_at":"2025-05-15T09:32:35.377Z","repository":{"id":34242469,"uuid":"173055585","full_name":"tkaitchuck/aHash","owner":"tkaitchuck","description":"aHash is a non-cryptographic hashing algorithm that uses the AES hardware instruction","archived":false,"fork":false,"pushed_at":"2024-08-20T23:45:41.000Z","size":1049,"stargazers_count":1048,"open_issues_count":25,"forks_count":101,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-16T20:52:14.625Z","etag":null,"topics":["aes","hash","hashing","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ahash","language":"Rust","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/tkaitchuck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2019-02-28T06:34:40.000Z","updated_at":"2024-11-14T18:47:02.000Z","dependencies_parsed_at":"2023-02-14T01:10:13.674Z","dependency_job_id":"294e82be-34c0-4076-bec9-4fe8c3cbb7a1","html_url":"https://github.com/tkaitchuck/aHash","commit_stats":{"total_commits":433,"total_committers":43,"mean_commits":"10.069767441860465","dds":0.6027713625866051,"last_synced_commit":"7d5c661a74b12d5bc5448b0b83fdb429190db1a3"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkaitchuck%2FaHash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkaitchuck%2FaHash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkaitchuck%2FaHash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkaitchuck%2FaHash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkaitchuck","download_url":"https://codeload.github.com/tkaitchuck/aHash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225245360,"owners_count":17443642,"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":["aes","hash","hashing","rust"],"created_at":"2024-08-04T04:03:36.695Z","updated_at":"2024-11-19T11:30:44.790Z","avatar_url":"https://github.com/tkaitchuck.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# aHash     ![Build Status](https://img.shields.io/github/actions/workflow/status/tkaitchuck/aHash/rust.yml?branch=master) ![Licence](https://img.shields.io/crates/l/ahash) ![Downloads](https://img.shields.io/crates/d/ahash) \n\nAHash is the [fastest](https://github.com/tkaitchuck/aHash/blob/master/compare/readme.md#Speed), \n[DOS resistant hash](https://github.com/tkaitchuck/aHash/wiki/How-aHash-is-resists-DOS-attacks) currently available in Rust.\nAHash is intended *exclusively* for use in in-memory hashmaps. \n\nAHash's output is of [high quality](https://github.com/tkaitchuck/aHash/blob/master/compare/readme.md#Quality) but aHash is **not** a cryptographically secure hash.\n\n## Design\n\nBecause AHash is a keyed hash, each map will produce completely different hashes, which cannot be predicted without knowing the keys.\n[This prevents DOS attacks where an attacker sends a large number of items whose hashes collide that get used as keys in a hashmap.](https://github.com/tkaitchuck/aHash/wiki/How-aHash-is-resists-DOS-attacks)\n\nThis also avoids [accidentally quadratic behavior by reading from one map and writing to another.](https://accidentallyquadratic.tumblr.com/post/153545455987/rust-hash-iteration-reinsertion)\n\n## Goals and Non-Goals\n\nAHash does *not* have a fixed standard for its output. This allows it to improve over time. For example,\nif any faster algorithm is found, aHash will be updated to incorporate the technique.\nSimilarly, should any flaw in aHash's DOS resistance be found, aHash will be changed to correct the flaw.\n\nBecause it does not have a fixed standard, different computers or computers on different versions of the code will observe different hash values.\nAs such, aHash is not recommended for use other than in-memory maps. Specifically, aHash is not intended for network use or in applications which persist hashed values.\n(In these cases `HighwayHash` would be a better choice)\n\nAdditionally, aHash is not intended to be cryptographically secure and should not be used as a MAC, or anywhere which requires a cryptographically secure hash.\n(In these cases `SHA-3` would be a better choice)\n\n## Usage\n\nAHash is a drop in replacement for the default implementation of the `Hasher` trait. To construct a `HashMap` using aHash \nas its hasher do the following:\n\n```rust\nuse ahash::{AHasher, RandomState};\nuse std::collections::HashMap;\n\nlet mut map: HashMap\u003ci32, i32, RandomState\u003e = HashMap::default();\nmap.insert(12, 34);\n```\nFor convenience, wrappers called `AHashMap` and `AHashSet` are also provided.\nThese do the same thing with slightly less typing.\n```rust\nuse ahash::AHashMap;\n\nlet mut map: AHashMap\u003ci32, i32\u003e = AHashMap::new();\nmap.insert(12, 34);\nmap.insert(56, 78);\n```\n\n## Flags\n\nThe aHash package has the following flags:\n* `std`: This enables features which require the standard library. (On by default) This includes providing the utility classes `AHashMap` and `AHashSet`.\n* `serde`: Enables `serde` support for the utility classes `AHashMap` and `AHashSet`.\n* `runtime-rng`: To obtain a seed for Hashers will obtain randomness from the operating system. (On by default)\nThis is done using the [getrandom](https://github.com/rust-random/getrandom) crate.\n* `compile-time-rng`: For OS targets without access to a random number generator, `compile-time-rng` provides an alternative.\nIf `getrandom` is unavailable and `compile-time-rng` is enabled, aHash will generate random numbers at compile time and embed them in the binary.\n* `nightly-arm-aes`: To use AES instructions on 32-bit ARM, which requires nightly. This is not needed on AArch64.\nThis allows for DOS resistance even if there is no random number generator available at runtime (assuming the compiled binary is not public).\nThis makes the binary non-deterministic. (If non-determinism is a problem see [constrandom's documentation](https://github.com/tkaitchuck/constrandom#deterministic-builds))\n\nIf both `runtime-rng` and `compile-time-rng` are enabled the `runtime-rng` will take precedence and `compile-time-rng` will do nothing.\nIf neither flag is set, seeds can be supplied by the application. [Multiple apis](https://docs.rs/ahash/latest/ahash/random_state/struct.RandomState.html)\nare available to do this.\n\n## Comparison with other hashers\n\nA full comparison with other hashing algorithms can be found [here](https://github.com/tkaitchuck/aHash/blob/master/compare/readme.md)\n\n![Hasher performance](https://docs.google.com/spreadsheets/d/e/2PACX-1vSK7Li2nS-Bur9arAYF9IfT37MP-ohAe1v19lZu5fd9MajI1fSveLAQZyEie4Ea9k5-SWHTff7nL2DW/pubchart?oid=1323618938\u0026format=image)\n\nFor a more representative performance comparison which includes the overhead of using a HashMap, see [HashBrown's benchmarks](https://github.com/rust-lang/hashbrown#performance)\nas HashBrown now uses aHash as its hasher by default.\n\n## Hash quality\n\nAHash passes the full [SMHasher test suite](https://github.com/rurban/smhasher). \n\nThe code to reproduce the result, and the full output [are checked into the repo](https://github.com/tkaitchuck/aHash/tree/master/smhasher).\n\n## Additional FAQ\n\nA separate FAQ document is maintained [here](https://github.com/tkaitchuck/aHash/blob/master/FAQ.md). \nIf you have questions not covered there, open an issue [here](https://github.com/tkaitchuck/aHash/issues).\n\n## License\n\nLicensed under either of:\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any\nadditional terms or conditions.\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkaitchuck%2FaHash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkaitchuck%2FaHash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkaitchuck%2FaHash/lists"}