All Projects → tkaitchuck → Ahash

tkaitchuck / Ahash

Licence: other
aHash is a non-cryptographic hashing algorithm that uses the AES hardware instruction

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Ahash

noble-hashes
Audited & minimal JS implementation of SHA2, SHA3, RIPEMD, BLAKE2/3, HMAC, HKDF, PBKDF2 & Scrypt
Stars: ✭ 213 (-15.14%)
Mutual labels:  hashing, hash
agent
hashtopolis.org
Stars: ✭ 19 (-92.43%)
Mutual labels:  hashing, hash
hash-checker
Fast and simple application that allows you to generate and compare hashes from files and text
Stars: ✭ 72 (-71.31%)
Mutual labels:  hashing, hash
EncrypC
🔑 File Encryption Application using Python.
Stars: ✭ 14 (-94.42%)
Mutual labels:  aes, hash
pthash
Fast and compact minimal perfect hash functions in C++.
Stars: ✭ 62 (-75.3%)
Mutual labels:  hashing, hash
prvhash
PRVHASH - Pseudo-Random-Value Hash. Hash functions, PRNG with unlimited period, randomness extractor. (Codename Gradilac/Градилак)
Stars: ✭ 194 (-22.71%)
Mutual labels:  hashing, hash
metrohash-rs
Rust MetroHash
Stars: ✭ 45 (-82.07%)
Mutual labels:  hashing, hash
Clhash
C library implementing the ridiculously fast CLHash hashing function
Stars: ✭ 220 (-12.35%)
Mutual labels:  hash, hashing
laravel-hashid
HashId Implementation on Laravel Eloquent ORM
Stars: ✭ 23 (-90.84%)
Mutual labels:  hashing, hash
jscrypto
Crypto library for Node/ES6/Typescript/Browser.
Stars: ✭ 20 (-92.03%)
Mutual labels:  aes, hash
node-blake2
All four BLAKE2 variants (blake2b, blake2bp, blake2s, blake2sp) with stream support for Node.js
Stars: ✭ 52 (-79.28%)
Mutual labels:  hashing, hash
crypthash-net
CryptHash.NET is a .NET multi-target library to encrypt/decrypt/hash/encode/decode strings and files, with an optional .NET Core multiplatform console utility.
Stars: ✭ 33 (-86.85%)
Mutual labels:  aes, hash
CryptoKnight
CryptoKnight is a general purpose cryptography desktop app
Stars: ✭ 18 (-92.83%)
Mutual labels:  hashing, aes
WebCrypto.swift
A small collection of cryptographic functions based on the JavaScript WebCrypto API.
Stars: ✭ 16 (-93.63%)
Mutual labels:  aes, hash
enigma
A fast, native, cryptographic engine for the web
Stars: ✭ 101 (-59.76%)
Mutual labels:  aes, hash
haiti
🔑 Hash type identifier (CLI & lib)
Stars: ✭ 287 (+14.34%)
Mutual labels:  hashing, hash
Dagon
Advanced Hash Manipulation
Stars: ✭ 155 (-38.25%)
Mutual labels:  hash, hashing
Util
A collection of useful utility functions
Stars: ✭ 201 (-19.92%)
Mutual labels:  hash, hashing
bromberg sl2
Cayley hashing as in "Navigating in the Cayley Graph of SL₂(𝔽ₚ)"
Stars: ✭ 32 (-87.25%)
Mutual labels:  hashing, hash
komihash
Very fast, high-quality hash function (non-cryptographic, C) + PRNG
Stars: ✭ 68 (-72.91%)
Mutual labels:  hashing, hash

aHash Build Status Licence Downloads

AHash is the fastest, DOS resistant hash currently available in Rust. AHash is intended exclusively for use in in-memory hashmaps.

AHash's output is of high quality but aHash is not a cryptographically secure hash.

Design

Because AHash is a keyed hash, each map will produce completely different hashes, which cannot be predicted without knowing the keys. This prevents DOS attacks where an attacker sends a large number of items whose hashes collide that get used as keys in a hashmap.

This also avoids accidentally quadratic behavior by reading from one map and writing to another.

Goals and Non-Goals

AHash does not have a fixed standard for its output. This allows it to improve over time. For example, if any faster algorithm is found, aHash will be updated to incorporate the technique. Similarly, should any flaw in aHash's DOS resistance be found, aHash will be changed to correct the flaw.

Because it does not have a fixed standard, different computers or computers on versions of the code will observe different hash values. As such aHash not recommended for use other than in-memory maps. Specifically, aHash is not intended for network use or in applications which persist hashed values. (In these cases HighwayHash would be a better choice)

Additionally, aHash is not intended to be cryptographly secure and should not be used as a MAC, or anywhere which requires a cryptographically secure hash. (In these cases SHA-3 would be a better choice)

Usage

AHash is a drop in replacement for the default implementation of the Hasher trait. To construct a HashMap using aHash its hasher do the following:

use ahash::{AHasher, RandomState};
use std::collections::HashMap;

let mut map: HashMap<i32, i32, RandomState> = HashMap::default();
map.insert(12, 34);

For convinence wrappers called AHashMap and AHashSet are also provided. These to the same thing with slightly less typing.

use ahash::AHashMap;

let mut map: AHashMap<i32, i32> = AHashMap::new();
map.insert(12, 34);
map.insert(56, 78);

Flags

The aHash package has the following flags:

  • std: This enables features which require the standard library. (On by default) This includes providing the utility classes AHashMap and AHashSet.
  • serde: Enables serde support for the utility classes AHashMap and AHashSet.
  • compile-time-rng: Whenever possible aHash will seed hashers with random numbers using the getrandom crate. This is possible for OS targets which provide a source of randomness. (see the full list.) For OS targets without access to a random number generator, compile-time-rng provides an alternative. If getrandom is unavailable and compile-time-rng is enabled, aHash will generate random numbers at compile time and embed them in the binary. This allows for DOS resistance even if there is no random number generator available at runtime (assuming the compiled binary is not public). This makes the binary non-deterministic, unless getrandom is available for the target in which case the flag does nothing. (If non-determinism is a problem see constrandom's documentation)

NOTE: If getrandom is unavailable and compile-time-rng is disabled aHash will fall back on using the numeric value of memory addresses as a source of randomness. This is somewhat strong if ALSR is turned on (it is by default) but for embedded platforms this will result in weak keys. As a result, it is recommended to use compile-time-rng anytime random numbers will not be available at runtime.

Comparison with other hashers

A full comparison with other hashing algorithms can be found here

Hasher perfromance

For more a more representative performance comparison which includes the overhead of using a HashMap, see HashBrown's benchmarks as HashBrown now uses aHash as its hasher by default.

Hash quality

AHash passes the full SMHasher test suite.

The code to reproduce the result, and the full output are checked into the repo.

Additional FAQ

A separate FAQ document is maintained here. If you have questions not covered there, open an issue here.

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].