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 GitHub - sfackler/rust-openssl: OpenSSL bindings for Rust, they should do the job just fine.

Are you referring to NTFS encryption? If so, you can do File Encryption - Win32 apps | Microsoft Docs using the winapi crate.

1 Like