Skip to content

Commit

Permalink
Add GxBuildHasher::with_seed (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
imartayan authored Jun 1, 2024
1 parent 3899143 commit 9c66ae7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ use std::collections::hash_map::RandomState;
#[rustversion::since(1.76)]
use std::hash::RandomState;

impl GxBuildHasher {
/// Creates a new builder using the provided seed.
///
/// # Warning ⚠️
/// Hardcoding a seed may make your [`Hasher`] vulnerable to DOS attacks.
/// It is recommended to use [`GxBuildHasher::default()`] for improved DOS resistance.
#[inline]
pub fn with_seed(seed: i64) -> GxBuildHasher {
// Use gxhash64 to generate an initial state from a seed
GxBuildHasher(unsafe { create_seed(seed) })
}
}

impl Default for GxBuildHasher {
#[inline]
fn default() -> GxBuildHasher {
Expand Down

0 comments on commit 9c66ae7

Please sign in to comment.