streaming_crypto/core_api/mod.rs
1// ## 📝 core-api/src/lib.rs
2
3/// Encrypts data by XORing each byte with 0xAA.
4///
5/// # Examples
6///
7/// ```
8/// use core_api::encrypt;
9///
10/// let data = vec![1, 2, 3];
11/// let encrypted = encrypt(&data);
12/// assert_eq!(encrypted[0], 1 ^ 0xAA);
13/// assert_eq!(encrypted[1], 2 ^ 0xAA);
14/// assert_eq!(encrypted[2], 3 ^ 0xAA);
15/// ```
16pub fn encrypt(data: &[u8]) -> Vec<u8> {
17 data.iter().map(|b| b ^ 0xAA).collect()
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn test_encrypt_core_api() {
26 let data = vec![1, 2, 3];
27 let encrypted = encrypt(&data);
28
29 // Check length matches
30 assert_eq!(encrypted.len(), data.len());
31
32 // Check XOR transformation
33 assert_eq!(encrypted[0], 1 ^ 0xAA);
34 assert_eq!(encrypted[1], 2 ^ 0xAA);
35 assert_eq!(encrypted[2], 3 ^ 0xAA);
36 }
37}
38
39// Shared and top level
40pub mod constants;
41pub mod types;
42pub mod utils;
43
44// Shared and top level module
45pub mod compression;
46pub mod headers;
47pub mod crypto;
48pub mod telemetry;
49
50pub mod recovery;
51pub mod parallelism;
52
53// Stream layers
54pub mod stream_v2;
55
56// Benchmark shared
57pub mod benchmarks;
58
59// -----------------------------------------------------------------------------
60// Prelude (Rust users)
61// -----------------------------------------------------------------------------
62pub mod prelude {
63
64}
65
66pub use stream_v2::*;