#Rust Build Script?? / Litcrypt at compiletime

11 messages · Page 1 of 1 (latest)

weary ermine
#

What are the "necessary things"?

#

what do you want the build script to do

#

generating a key is easy. just have build.rs generate a random number or something

pure citrus
#

nah,
replace stings/slices with the litcrypt macro
the reason I haven't been able to do it is because each ".*" is different
could be in a string::from or in a print()

so maybe there was a way that rust could handle all these cases the same way or something idk

0 experience w macros

tried to look once and there was scary characters

#

necessary things being
generating the key
adding
the
#[macro_use]
extern crate litcrypt;

use_litcrypt!();

to main.rs

and then replacing the strings

weary ermine
#

Replacing every string in the whole program?

#

I mean, theoretically yes - you would basically need to write/use a whole rust parser and ast

#

Practically no, modifying code is not really the job of build.rs. It's common to use it to generate new code files, which you can import

#

So - you could have it generate code with a random a key, maybe invoke global a litcrypt constructor, and put that into a generated source file.

#

But reading and replacing existing code is totally not what build.rs is for

#

If you organized all of your secrets into one file, say a json file in the project, build.rs could read that and generate a module with all the encrypted strings