MCPcopy Create free account
hub / github.com/echQoQ/RustSL / encrypt_string

Function encrypt_string

rsl-macros/src/lib.rs:159–173  ·  view source on GitHub ↗
(input: TokenStream)

Source from the content-addressed store, hash-verified

157/// A procedural macro that encrypts a string literal at compile time.
158#[proc_macro]
159pub fn encrypt_string(input: TokenStream) -> TokenStream {
160 let input = parse_macro_input!(input as LitStr);
161 let string = input.value();
162
163 // Set key to seeded env key or default
164 let key = env::var("CRYPTIFY_KEY").unwrap_or_else(|_| "xnasff3wcedj".to_string());
165
166 let encrypted_string = xor_cipher(&string, &key);
167
168 let output = quote! {
169 cryptify::decrypt_string(#encrypted_string).as_ref()
170 };
171
172 TokenStream::from(output)
173}
174
175fn xor_cipher(input: &str, key: &str) -> String {
176 let key_bytes = key.as_bytes();

Callers

nothing calls this directly

Calls 1

xor_cipherFunction · 0.85

Tested by

no test coverage detected