StackString

Struct StackString 

Source
pub struct StackString<const N: usize> { /* private fields */ }

Implementations§

Source§

impl<const N: usize> StackString<N>

Source

pub fn new() -> Self

Source

pub fn from_encrypted(encrypted: &[u8], key: u8) -> Self

Examples found in repository?
examples/basic.rs (line 39)
3fn main() {
4    let secret = obf_string!("super secret password");
5    println!("decoded: {}", secret);
6
7    let hash = ct_hash!("test string");
8    println!("compile time hash: {:#x}", hash);
9
10    let protected_value = confuse_flow!({
11        let x = 42;
12        let y = x * 2;
13        y + 10
14    });
15    println!("result: {}", protected_value);
16
17    let hidden_result = hide_call!({
18        calculate_something(100)
19    });
20    println!("hidden calculation: {}", hidden_result);
21
22    let mut buffer = vec![1, 2, 3, 4, 5];
23    xor_buffer(&mut buffer, 0xAA);
24    println!("obfuscated buffer: {:?}", buffer);
25    xor_buffer(&mut buffer, 0xAA);
26    println!("deobfuscated buffer: {:?}", buffer);
27
28    let original = 123456789u64;
29    let encoded = encode_value(original);
30    let decoded = decode_value(encoded);
31    println!("original: {}, encoded: {}, decoded: {}", original, encoded, decoded);
32
33    let data = b"sensitive data here";
34    let encrypted = multilayer_encrypt(data, 3);
35    let decrypted = multilayer_decrypt(&encrypted, 3);
36    println!("multilayer encryption works: {}", data == &decrypted[..]);
37
38    let encrypted_bytes = [0x3f, 0x30, 0x37, 0x3a, 0x3b];
39    let stack_str = StackString::<32>::from_encrypted(&encrypted_bytes, 0x55);
40    println!("stack string: {}", stack_str.as_str());
41
42    let scrambled = scramble_int(42069);
43    let original_int = unscramble_int(scrambled);
44    println!("int obfuscation: {} -> {} -> {}", 42069, scrambled, original_int);
45
46    let func_result = indirect_call(dummy_func);
47    println!("indirect function call result: {}", func_result);
48}
Source

pub fn as_str(&self) -> &str

Examples found in repository?
examples/basic.rs (line 40)
3fn main() {
4    let secret = obf_string!("super secret password");
5    println!("decoded: {}", secret);
6
7    let hash = ct_hash!("test string");
8    println!("compile time hash: {:#x}", hash);
9
10    let protected_value = confuse_flow!({
11        let x = 42;
12        let y = x * 2;
13        y + 10
14    });
15    println!("result: {}", protected_value);
16
17    let hidden_result = hide_call!({
18        calculate_something(100)
19    });
20    println!("hidden calculation: {}", hidden_result);
21
22    let mut buffer = vec![1, 2, 3, 4, 5];
23    xor_buffer(&mut buffer, 0xAA);
24    println!("obfuscated buffer: {:?}", buffer);
25    xor_buffer(&mut buffer, 0xAA);
26    println!("deobfuscated buffer: {:?}", buffer);
27
28    let original = 123456789u64;
29    let encoded = encode_value(original);
30    let decoded = decode_value(encoded);
31    println!("original: {}, encoded: {}, decoded: {}", original, encoded, decoded);
32
33    let data = b"sensitive data here";
34    let encrypted = multilayer_encrypt(data, 3);
35    let decrypted = multilayer_decrypt(&encrypted, 3);
36    println!("multilayer encryption works: {}", data == &decrypted[..]);
37
38    let encrypted_bytes = [0x3f, 0x30, 0x37, 0x3a, 0x3b];
39    let stack_str = StackString::<32>::from_encrypted(&encrypted_bytes, 0x55);
40    println!("stack string: {}", stack_str.as_str());
41
42    let scrambled = scramble_int(42069);
43    let original_int = unscramble_int(scrambled);
44    println!("int obfuscation: {} -> {} -> {}", 42069, scrambled, original_int);
45
46    let func_result = indirect_call(dummy_func);
47    println!("indirect function call result: {}", func_result);
48}

Auto Trait Implementations§

§

impl<const N: usize> Freeze for StackString<N>

§

impl<const N: usize> RefUnwindSafe for StackString<N>

§

impl<const N: usize> Send for StackString<N>

§

impl<const N: usize> Sync for StackString<N>

§

impl<const N: usize> Unpin for StackString<N>

§

impl<const N: usize> UnwindSafe for StackString<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V