I want to convert a [u32; 4]
to a [u8; 16]
in place.
I know it is possible to use bitwise operation to get the 16 u8
from the 4 u32
. But I want to convert the array in place. How to do this using safe Rust or unsafe Rust?
let buffer: [u32; 4] = [1, 2, 3, 4];
let hash: [u8; 16]; // how to convert from buffer to hash?
background information: I am calculating a 128-bit hash value, where the [u32; 4]
is a buffer holding 4 u32
.
And I want to convert the array to a [u8; 16]
, as the final hash.