encryption_macros_utils/
lib.rs1use encryption_macros_key_generation::generate_key;
2use hex::decode;
3
4pub static ENCRYPTION_KEY_BUFFER : &'static str = generate_key!();
5
6
7pub fn xor(bytes: &mut [u8]) {
10 for (b, k) in bytes.iter_mut().zip(decode(ENCRYPTION_KEY_BUFFER).unwrap()) {
11 *b ^= k
12 }
13}
14
15pub struct Key<'a> {
16 position : usize,
17 buffer : &'a [u8]
18}
19
20impl<'a> Iterator for Key<'a> {
21 type Item = u8;
22 fn next(&mut self) -> Option<Self::Item> {
23 self.position += 1;
24 if self.position > self.buffer.len() {
25 self.position = 0;
26 }
27 return Some(self.buffer[self.position])
28 }
29}