dir_zip is a Rust-based tool that creates password-protected ZIP files from directories. It retrieves the password either from an environment variable or prompts the user to input one if not set. It also supports parallel file processing for faster performance.
- Creates password-protected ZIP files.
- Retrieves the password from the
ZIP_PASSWORDenvironment variable. - Prompts the user to enter the password if the environment variable is not set.
- Supports parallel file processing using the
rayoncrate for faster processing.
-
Clone the repository:
git clone https://github.com/your-username/dir_zip.git cd dir_zip -
Build the project using Cargo:
cargo build --release
-
Using Environment Variable: The program can use the
ZIP_PASSWORDenvironment variable to securely set the password. This is the recommended method as it keeps the password outside of your code.-
On Linux/macOS:
export ZIP_PASSWORD="your_password"
-
On Windows:
set ZIP_PASSWORD="your_password"
After setting the environment variable, you can run the program, and it will use the password from the variable to create the ZIP files.
-
-
Prompting for Password: If the
ZIP_PASSWORDenvironment variable is not set, the program will prompt you to enter a password at runtime.
To zip the files in a directory, run the program and provide the directory path as an argument:
./target/release/dir_zip /path/to/directory-
Set the environment variable:
export ZIP_PASSWORD="supersecret123"
-
Run the program:
./target/release/dir_zip /path/to/directory
-
Expected Output:
Successfully created password-protected ZIP: file1.zip Successfully created password-protected ZIP: file2.zip Successfully created password-protected ZIP: file3.zip
-
Run the program without setting the environment variable:
./target/release/dir_zip /path/to/directory
-
Program will prompt for a password:
The `ZIP_PASSWORD` environment variable is not set. You can set it by running: For Linux/macOS: export ZIP_PASSWORD="your_password" For Windows: set ZIP_PASSWORD="your_password" Please enter a password for the ZIP file: -
Enter the password:
mypassword123 -
Expected Output:
Successfully created password-protected ZIP: file1.zip Successfully created password-protected ZIP: file2.zip Successfully created password-protected ZIP: file3.zip
-
Invalid directory provided: If you run the program with an invalid directory, the program will output an error:
./target/release/dir_zip /invalid/path
-
Expected Output:
The provided path is not a valid directory.
- The program zips each file or folder inside the provided directory into a separate password-protected ZIP file.
- It uses the
rayoncrate for parallel processing, meaning the files will be zipped in parallel for better performance on large directories. - The password can be provided either through an environment variable (
ZIP_PASSWORD) or via a prompt if the variable is not set. - The ZIP files will be created in the same directory as the files that are being zipped.
- If the
ZIP_PASSWORDenvironment variable is not set, the program provides instructions for setting it. - The program will prompt for a password only if the environment variable is missing.
- The ZIP files will be created using the
zipcommand-line tool, so ensure thatzipis installed on your system.
This project is licensed under the GNU GPLv3 License. See the LICENSE file for more details.