MCPcopy Create free account
hub / github.com/Kudaes/MFTool / new_random

Method new_random

data/src/lib.rs:536–548  ·  view source on GitHub ↗
(key_len: usize)

Source from the content-addressed store, hash-verified

534
535impl XorCipher {
536 pub fn new_random(key_len: usize) -> Self {
537 let seed = SystemTime::now()
538 .duration_since(UNIX_EPOCH)
539 .expect("")
540 .as_nanos() as u64;
541 let mut state = seed;
542 let mut key = Vec::with_capacity(key_len);
543 for _ in 0..key_len {
544 state = (A.wrapping_mul(state).wrapping_add(C)) % M;
545 key.push((state & 0xFF) as u8);
546 }
547 XorCipher { key }
548 }
549
550 #[inline]
551 pub fn apply(&self, data: &mut [u8]) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected