Last active
August 14, 2022 11:45
-
-
Save gre/9e9ff87a0631bcf71a90e032d68ad6a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// need libs: rand + bs58 | |
use rand::rngs::StdRng; | |
fn rng_from_fxhash(hash: String) -> impl Rng { | |
let mut bs = [0; 32]; | |
let max_chars = 43; // hack to not overflow the bs array | |
bs58::decode( | |
hash.chars().skip(2).take(max_chars).collect::<String>(), | |
) | |
.into(&mut bs) | |
.unwrap(); | |
let rng = StdRng::from_seed(bs); | |
return rng; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment