Is a wrapper uniting the crypdir
and cred
commands to encrypt and decrypt directories.
Gets encryption keys and PBKDF2 iteration count from a credentials file created by the cred
command. Then encrypts or decrypts a directory using the retrieved keys and iteration count.
- Encrypt (-e): Compress and encrypt a directory into a secure file.
- Decrypt (-d): Decrypt and decompress an encrypted file into a directory.
- Retrieves encryption keys and PBKDF2 iteration count using a credential file (
cred
). - Password input can be provided interactively or piped.
crypdir
: Tool for encryption (-e
) and decryption (-d
).cred
: Used for retrieving encryption keys and iteration counts.
Important:
When specifying<cred keys>
, they must includeKEY
andITER
in that order like "settings_key settings_iter".
./credcrypdir [-d|-e] <credfile> <cred keys> <source> <target>
Note
The directory itself is included, not only its contents. Encrypting with
-d
: Decrypt and decompress a file.-e
: Encrypt and compress a directory.<credfile>
: Credential file for retrieving encryption keys and iteration counts.<cred keys>
: These are the names of the keys (space separated) in the credentials vault holding encryption key and iteration count (e.g.,MY_KEY MY_ITER
).<source>
:- For
-d
: Encrypted file to decrypt. - For
-e
: Directory to encrypt and compress.
- For
<target>
:- For
-d
: Directory where decrypted files will be extracted. - For
-e
: Output file name for the encrypted archive.
- For
./script.sh -e credfile "KEY ITER" my_directory output_file.enc
- Encrypts and compresses
my_directory
intooutput_file.enc
. - Retrieves the encryption key and iteration count from
credfile
using thecred
command.
./script.sh -d credfile "KEY ITER" encrypted_file.enc target_directory
- Decrypts
encrypted_file.enc
and extracts its contents intotarget_directory
. - Retrieves the decryption key and iteration count from
credfile
.
- If data is piped into the script, the password is read from the pipe.
- If not, the script prompts for the password interactively.
- Use strong and unique passwords for each operation.
- Store the credential file (
credfile
) securely to prevent unauthorized access. - Consider increasing the PBKDF2 iteration count for added security.
- The script ensures all necessary inputs (
KEY
andITER
) are retrieved successfully from thecred
command. - Provides clear error messages for any issues during encryption or decryption.