1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use mem;
/// Performs XOR encoding or decoding on the provided byte slice using the specified key.
///
/// # Arguments
///
/// * `input` - The input byte slice to be encoded or decoded.
/// * `key` - The key used for XOR encoding or decoding. It is repeated cyclically if shorter than the input.
///
/// # Returns
///
/// A `Vec<u8>` containing the result of the XOR operation.
///
/// # Examples
///
/// ```
/// use stegano::utils::xor_encode_decode;
///
/// let input = b"Hello, World!";
/// let key = "secret_key";
/// let encoded = xor_encode_decode(input, key);
/// let decoded = xor_encode_decode(&encoded, key);
/// assert_eq!(input, decoded.as_slice());
/// ```
/// Converts a 64-bit unsigned integer to an array of 8 bytes.
///
/// # Arguments
///
/// * `value` - The 64-bit unsigned integer to be converted.
///
/// # Returns
///
/// An array of 8 bytes representing the input value.
///
/// # Examples
///
/// ```
/// use stegano::utils::u64_to_u8_array;
///
/// let value = 1234567890u64;
/// let byte_array = u64_to_u8_array(value);
/// assert_eq!(value.to_ne_bytes(), byte_array);
/// ```