Encrypt a specific folder with a path


I would like to use Rust to encrypt a specific folder with a path. under Windows E: \ example folder \ example file How can I define the path within the program and then encrypt and decrypt it?

I do not need a graphical interface.



I don’t know of any existing crate that encrypts folders. You’ll have to break down the problem into parts:

  1. Gather files from the folder and put them in some kind of archive.
  2. Encrypt the archive.

For the first, there are crates like tar, zip and ar.

For the second, I’m not sure. Search crates.io for something that might suit you. If you build your own encryption from primitives, remember to do key stretching, and authentication of encrypted content.



For the seconds part I can recommend the openssl bindings https://github.com/sfackler/rust-openssl, they should do the job just fine.



Are you referring to NTFS encryption? If so, you can do https://docs.microsoft.com/en-us/windows/desktop/fileio/file-encryption using the winapi crate.

1 Like