Macro obfstr::obfstmt

source ·
macro_rules! obfstmt {
    ($($stmt:stmt;)*) => { ... };
}
Expand description

Statement control flow obfuscation.

Given a sequence of statements obfuscates the relationship between each statement.

Limitations

Variables cannot be declared inside the obfuscated statements, declare and initialize any variables needed beforehand. Control flow analysis will fail. The declared variables will need to be mutable and have an initial value.

There’s a risk that the obfuscated code fails to work due to two statements generating the same random key accidentally. This is presented at runtime with an infinite loop pending extra validation checks.

Examples

let mut tmp = 0;
obfstr::obfstmt! {
	tmp = 2;
	tmp *= 22;
	tmp -= 12;
	tmp /= 3;
}
assert_eq!(tmp, 10);