This Python script is designed to decrypt and reencrypt sensitive fields in a YAML file using the AES encryption algorithm. The decryption and reencryption process involves replacing specific placeholders in the YAML file with their decrypted counterparts.
The script relies on the following Python libraries:
Crypto.Cipher
from thepycryptodome
package for AES encryptionbase64
for base64 encoding and decodingyaml
for YAML file processingshutil
for file manipulationsys
for handling command-line arguments
-
Install Python: Ensure that you have Python installed on your system. You can download Python from python.org.
-
Install Dependencies: Install the required dependencies using the following command:
pip install -r requirements.txt
-
Clone or Download the Repository: Clone this repository or download the script (main.py) to your local machine.:
git clone https://github.com/LorenzoNeriCap4Lab/CryptoDecrypter.git
-
Navigate to the Script Directory: Move to the directory where the script is located.
cd path/to/script/directory
To use the script, run it from the command line with the following arguments:
python main.py input_file_path output_file_path original_key new_key
- input_file_path: Path to the input YAML file that contains sensitive fields.
- output_file_path: Path to the output YAML file where the modified data will be saved.
- original_key: 16-byte original key used for decryption (provided as a command-line argument).
- new_key: 16-byte new key used for re-encryption (provided as a command-line argument).
python main.py test_input.yaml test_output.yaml 0123456789abcdef fedcba9876543210
This command will read the YAML data from secure.prod.yaml, replace sensitive fields, and write the modified YAML to secure.loc_prod.yaml. The provided original and new keys are used for decryption and re-encryption, respectively.
- Ensure that the script is executed in a secure environment, as it deals with sensitive information.
- Keep the original and new keys secure and do not share them openly.
- Backup your YAML files before running the script to avoid data loss.
- For any issues or inquiries, feel free to create ticket on the GitHub repository