rust_native_obf/
flow.rs

1pub const fn gen_flow_keys<const N: usize>(base: u32, stmts: &[&'static str; N]) -> [u32; N] {
2    let mut keys = [0u32; N];
3    let mut state = base;
4    let mut i = 0;
5    while i < N {
6        let stmt_bytes = stmts[i].as_bytes();
7        let mut j = 0;
8        while j < stmt_bytes.len() {
9            state ^= (stmt_bytes[j] as u32).wrapping_shl(((j & 3) * 8) as u32);
10            state = state.wrapping_mul(0x27d4eb2d);
11            j += 1;
12        }
13        keys[i] = state;
14        state = state.rotate_left(13);
15        i += 1;
16    }
17    keys
18}
19
20#[macro_export]
21macro_rules! obf_block {
22    ($code:block) => {{
23        let choice = $crate::ct_rand!(u8) % 3;
24        match choice {
25            0 => {
26                $crate::noise_loop(20);
27                $code
28            }
29            1 => {
30                $crate::stack_trash();
31                $code
32            }
33            _ => {
34                $crate::fake_compute(42);
35                $code
36            }
37        }
38    }};
39}
40