Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
frederikhors opened this issue Dec 1, 2023 · 10 comments
Open

Comments

@frederikhors
Copy link
Contributor

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?

@pyrossh
Copy link
Owner

pyrossh commented Dec 2, 2023

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.

@frederikhors
Copy link
Contributor Author

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

@BBaoVanC
Copy link
Contributor

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.

@frederikhors
Copy link
Contributor Author

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.

@BBaoVanC
Copy link
Contributor

BBaoVanC commented Dec 28, 2023

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.

@pyrossh
Copy link
Owner

pyrossh commented Dec 28, 2023

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.

@AzureMarker
Copy link
Collaborator

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?).

@frederikhors
Copy link
Contributor Author

frederikhors commented Jan 9, 2024

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
Copy link
Contributor Author

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 frederikhors changed the title Is there a way to encrypt embedded file? Is there a way to encrypt embedded file? Maybe before/after hooks? Jan 9, 2024
@Z1xus
Copy link

Z1xus commented Apr 22, 2024

i fw it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants