hi, so it's likely you'll want a procedural macro to do this, as i doubt a declarative macro will have the capabilities to do this. since you don't want to add things and would like to instead replace the content entirely, you don't want to write a function or derive proc macro, but likely an attribute proc macro. this is a good site that has info on these, i highly recommend reading it: https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros
an attribute proc macro can read the entirety of the entered code, parse it, and modify it in anyway and it returns new code that the compiler will see and process.
an important question i have is what sort of encryption do you want to use. do you want it to be unclear what the code does to the person running the source code or someone decompiling the binary?