pub struct Shake256 { /* private fields */ }Expand description
The SHAKE256 extendable-output function
§Examples
const PSEUDO_RANDOM_BYTES: [u8; 64] = Shake256::new()
.update(b"The quick brown fox ")
.update(b"jumps over the lazy dog")
.finalize();
assert_eq!(
[
0x2f, 0x67, 0x13, 0x43, 0xd9, 0xb2, 0xe1, 0x60, 0x4d, 0xc9, 0xdc, 0xf0, 0x75, 0x3e,
0x5f, 0xe1, 0x5c, 0x7c, 0x64, 0xa0, 0xd2, 0x83, 0xcb, 0xbf, 0x72, 0x2d, 0x41, 0x1a,
0x0e, 0x36, 0xf6, 0xca, 0x1d, 0x01, 0xd1, 0x36, 0x9a, 0x23, 0x53, 0x9c, 0xd8, 0x0f,
0x7c, 0x05, 0x4b, 0x6e, 0x5d, 0xaf, 0x9c, 0x96, 0x2c, 0xad, 0x5b, 0x8e, 0xd5, 0xbd,
0x11, 0x99, 0x8b, 0x40, 0xd5, 0x73, 0x44, 0x42
],
PSEUDO_RANDOM_BYTES,
);#![feature(const_mut_refs)]
const ROUND_CONSTANTS_LEN: usize = 16;
const ROUND_CONSTANTS: [u128; ROUND_CONSTANTS_LEN] = {
let shake = Shake256::new()
.update(b"The quick brown fox ")
.update(b"jumps over the lazy dog");
let mut reader = shake.finalize_xof();
let mut output = [0; ROUND_CONSTANTS_LEN];
let mut i = 0;
while i < ROUND_CONSTANTS_LEN {
let mut buf = [0; 16];
reader.read(&mut buf);
output[i] = u128::from_be_bytes(buf);
i += 1;
}
output
};
assert_eq!(
[
63008913119763991345740861509526773729,
122934861405288129899227865927808120522,
38557047524252432877084375354350394799,
208139318032057588670393890858232661058,
253672765511221901359815901266029094236,
24673942916364082950221119418287074493,
314501551299016784988697613270261126631,
55846473543301730160082510643706458461,
74217159387677683656408416866508597390,
103097936643341605695740861737581768184,
43427127028232698635034841870476065529,
30671809218547569588332151812578484838,
234968987069139406291454845949508600001,
174416227018858056231916805199588046174,
206220167108618043277683992075133751175,
50389517484914419772600260972881863524,
],
ROUND_CONSTANTS,
);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shake256
impl RefUnwindSafe for Shake256
impl Send for Shake256
impl Sync for Shake256
impl Unpin for Shake256
impl UnwindSafe for Shake256
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more