Skip to content
Snippets Groups Projects
Commit 0a628a8e authored by qh11's avatar qh11
Browse files

Update hash.rs

parent 678722eb
No related branches found
No related tags found
No related merge requests found
......@@ -109,6 +109,14 @@ impl PartialOrd for H256 {
}
}
pub fn random_hash() -> H256 {
let mut rng = rand::thread_rng();
let random_bytes: Vec<u8> = (0..32).map(|_| rand::random()).collect();
let mut raw_bytes = [0; 32];
raw_bytes.copy_from_slice(&random_bytes);
(&raw_bytes).into()
}
#[cfg(any(test, test_utilities))]
pub fn generate_random_hash() -> H256 {
let mut rng = rand::thread_rng();
......@@ -116,4 +124,4 @@ pub fn generate_random_hash() -> H256 {
let mut raw_bytes = [0; 32];
raw_bytes.copy_from_slice(&random_bytes);
(&raw_bytes).into()
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment