rust-embed icon indicating copy to clipboard operation
rust-embed copied to clipboard

Is there a way to encrypt embedded file? Maybe before/after hooks?

Open frederikhors opened this issue 2 years ago • 10 comments

Thanks for your work.

I just found out https://github.com/anvie/litcrypt.rs. I'm wondering if there is a way to encrypt the content of some files using it.

What can you suggest?

frederikhors avatar Dec 01 '23 01:12 frederikhors

Thanks frederikhors. At this point rust-embed only supports folders so if we do add such a feature it would have to be an entire folder. We do have a compress feature which does something similar.

pyrossh avatar Dec 02 '23 07:12 pyrossh

Yeah. It would be ok too. Because I can encrypt some words in the entire folder.

frederikhors avatar Dec 26 '23 22:12 frederikhors

I feel like "encrypt" could be too vague and niche, it might be best to just use a build script to encrypt the files, and then use RustEmbed on the output directory of that script.

BBaoVanC avatar Dec 27 '23 06:12 BBaoVanC

I feel like "encrypt" could be too vague and niche, it might be best to just use a build script to encrypt the files, and then use RustEmbed on the output directory of that script.

I do not understand: I need to "decrypt" content of those file at runtime.

frederikhors avatar Dec 27 '23 08:12 frederikhors

I feel like "encrypt" could be too vague and niche, it might be best to just use a build script to encrypt the files, and then use RustEmbed on the output directory of that script.

I do not understand: I need to "decrypt" content of those file at runtime.

I guess then you could just do the XOR "encryption" manually then, instead of using litcrypt at all. I didn't look closely enough at the library to realize that what I said earlier wouldn't work.

BBaoVanC avatar Dec 28 '23 01:12 BBaoVanC

So this would be a new feature litcrypt which would encrypt the entire folder and expects the LITCRYPT_ENCRYPT_KEY env variable. That seems fine I guess.

Just wondering if its worth exposing a generic interface for this sort of stuff which can be implemented by the application instead of putting it under a feature. Maybe before/after hooks.

pyrossh avatar Dec 28 '23 11:12 pyrossh

I don't think the library should have a specific feature just for encryption, especially if we only provide a specific algorithm. It sounds like there's a need for a pre-embed hook (maybe by passing in the procedural macro that should annotate the file data once it's been read from disk?).

AzureMarker avatar Dec 30 '23 04:12 AzureMarker

I guess then you could just do the XOR "encryption" manually then, instead of using litcrypt at all.

I do not understand, can you write a small example? @BBaoVanC

frederikhors avatar Jan 09 '24 22:01 frederikhors

Maybe before/after hooks.

It sounds like there's a need for a pre-embed hook

I think the same. Hooks seem perfect for cases like this.

I'll change the title.

frederikhors avatar Jan 09 '24 22:01 frederikhors

i fw it

Z1xus avatar Apr 22 '24 20:04 Z1xus