optparse
Crypto
hashlib
base64
python3 pyencrypt.py [options]
Options:
-h, --help show this help message and exit
-f FILE, --file=FILE File to Encrypt
-d DIRECTORY, --directory=DIRECTORY Directory to Encrypt
-k KEY_FILE, --key=KEY_FILE Key file (without the extension of .key) to encrypt, defaults to key.key
-p PATH, --path=PATH path where the target file/directory is located (Eg., /home/Desktop if the file to encrypt is sample.txt in /home/Desktop/sample.txt)
-e, --encrypt Encrypt the file/directory
-u, --decrypt decrypt the file/directory
-v, --verbose Verbosity of the Actions
-l KEY_PATH, --key_path=KEY_PATH Path where the key is located (Eg., /home/Desktop if the key is in /home/Desktop directory)
1. python3 encrypt.py -e -f sample.txt
by default this generates the key "key.key" in current directory of the encrypt.py.
2. python3 encrypt.py -e -f sampledir
by default this generates the key "key.key" in current directory of the encrypt.py.
3. python3 encrypt.py -e -f sample.txt -p /home/user
by default this generates the key "key.key" in current directory of the encrypt.py.
4. python3 encrypt.py -u -f sampledir -p /home/user
by default this uses the key "key.key" in current directory of the encrypt.py.
5. python3 encrypt.py -u -f sample.txt
by default this uses the key "key.key" in current directory of the encrypt.py.
6. python3 encrypt.py -u -f sampledir
by default this uses the key "key.key" in current directory of the encrypt.py.
7. python3 encrypt.py -u -f sample.txt -p /home/user
by default this uses the key "key.key" in current directory of the encrypt.py.
8. python3 encrypt.py -u -f sampledir -p /home/user
by default this uses the key "key.key" in current directory of the encrypt.py.
Example:
9. python3 encrypt.py -u -f sampledir -p /home/user -k key2
by default this uses the key "key2.key" in current directory of the encrypt.py. Notice that the ".key" extension is not specified here. Only specify the prefix.
10. python3 encrypt.py -u -f sampledir -p /home/user -k key2 -l /home/user
This execution will use /home/user/key2.key to encrypt the files in /home/user/sampledir
11. python3 encrypt.py -e -f sample.txt -p /home/user -k key2
by default this uses the key "key2.key" in current directory of the encrypt.py. Notice that the ".key" extension is not specified here. Only specify the prefix.
12. python3 encrypt.py -u -f sample.txt -p /home/user -k key2 -l /home/user -v
This execution will use /home/user/key2.key to encrypt the file in /home/user/sample.txt This will print verbose output
13. python3 encrypt.py -[u/e] -[f/d] [file/dir] [[-p /home/user] / blank] [[-k key2] / blank] [[-l /home/user] / blank]
Here the blank denotes that this argument is not needed if the files are in the current directory
Please store the key file somewhere safely. If lost, then it is nearly Impossible to recover the encrypted data.
Now inorder to avoid the problem of forgetting the key files, I've Included the functionality, that encrypts and decrypts with password.