#hashing #hash #fixed-length #algorithm #hash-values

hash-algorithms

Hash, generally translated as hash, hash, or transliterated as hash, is to transform any length of input (also known as pre image) into fixed length output through hash algorithm, and the output is the hash value. This transformation is a kind of compression mapping, that is, the space of hash value is usually much smaller than the space of input, different inputs may hash into the same output, so it is impossible to determine the unique input value from hash value. In short, it is a function that compresses messages of any length to a message digest of a fixed length.

1 unstable release

0.1.0 Jun 12, 2021

#2337 in Algorithms

Download history 36/week @ 2024-01-01 127/week @ 2024-01-08 74/week @ 2024-01-15 74/week @ 2024-01-22 51/week @ 2024-01-29 51/week @ 2024-02-05 81/week @ 2024-02-12 185/week @ 2024-02-19 247/week @ 2024-02-26 228/week @ 2024-03-04 233/week @ 2024-03-11 185/week @ 2024-03-18 146/week @ 2024-03-25 210/week @ 2024-04-01 164/week @ 2024-04-08 157/week @ 2024-04-15

681 downloads per month

MIT license

10KB
203 lines

hash-algorithms

Description

Hash, generally translated as hash, hash, or transliterated as hash, is to transform any length of input (also known as pre image) into fixed length output through hash algorithm, and the output is the hash value. This transformation is a kind of compression mapping, that is, the space of hash value is usually much smaller than the space of input, different inputs may hash into the same output, so it is impossible to determine the unique input value from hash value. In short, it is a function that compresses messages of any length to a message digest of a fixed length.

How To Use

fn main() {
    let hello = "hello";
    println!("additive_hash {}", additive_hash(hello, 131));
    println!("rotating_hash {}", rotating_hash(hello, 131));
    println!("one_by_one_hash {}", one_by_one_hash(hello));
    println!("bernstein {}", bernstein(hello));
    println!("int_hash {}", int_hash(73));
    // println!("{}", rs_hash(hello));
    println!("js_hash {}", js_hash(hello));
    println!("pjw_hash {}", pjw_hash(hello));
    println!("elf_hash {}", elf_hash(hello));
    println!("sdbm_hash {}", sdbm_hash(hello));
    println!("djb_hash {}", djb_hash(hello));
    println!("djb_hash {}", dek_hash(hello));
    println!("ap_hash: {}", ap_hash(hello));
    println!("java_hash {}", java_hash(hello));
}

License

This library is licensed under MIT license. See LICENSE for details.

No runtime deps