You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/embed/rust/src/trezorhal/random.rs

12 lines
266 B

pub fn uniform(n: u32) -> u32 {
unsafe { super::ffi::random_uniform(n) }
}
pub fn shuffle<T>(slice: &mut [T]) {
// Fisher-Yates shuffle.
for i in (1..slice.len()).rev() {
let j = uniform(i as u32 + 1) as usize;
slice.swap(i, j);
}
}