Interactive command-line Python encryption program using AES 256-bit with CBC
This is a support document providing documentation and instructions for the author’s submission to this assessment. The assessment task was to create a program that, implementing cryptography.io, encrypted a user-defined file using the AES algorithm in CBC mode with a 256-bit key. Below is a summary of each function of the program created by the author (the program, this program). They are in order of usage in the encryption and decryption processes respectively. These summaries are high-level and explain what each function does in human readable terms, as a supplement to reading the source code.
- Python 3+
- Read and write permissions by the user to the directory where program runs
- A terminal-style interface to the system, that can interact with the directory where the program runs
- The Python libraries imported by the program have been installed
- The Initialisation Vector generated by the os.urandom() function is sufficiently cryptographically secure for this program as a learning tool
- Python environment variables, such as PATH, are already and correctly configured
- Messages for encryption are in a human language, such as but not limited to English
- Files use UTF-8 or ISO/IEC 8859 (also known in Windows Notepad as ‘ANSI’) encoding
- The executed program has permission to read existing files and create new files in its own directory
- Submitted code has only been tested on Windows 10 x64
- While Python code is generally quite portable for such simple applications, there is a small chance that another operating system may cause the program to malfunction
- It is recommended to execute this program on Windows 10 x64
The following instructions supplement the prompts written into the program:
- Place the program file in a directory
- Also place an input text file, containing the message to be encrypted
- Execute the program
- At the prompt, enter ‘1’ to begin the encryption process
- At the prompt, enter a password with which to encrypt the message
- At the prompt, enter the name of the input file containing the message to be encrypted
- At the prompt, enter the name of the output file where encrypted data will be written
- Identify a file that has previously been encrypted by this program
- Co-locate the program with this file
- Execute the program
- At the prompt, enter ‘2’ to decrypt the file
- At the prompt, enter the password that you used to encrypt the file
- At the prompt, enter the name of the file to be decrypted
- View the decrypted message
- Symmetric Encryption Code Source https://cryptography.io/en/latest/hazmat/primitives/symmetric-encryption/
- Padding Code Source https://cryptography.io/en/latest/hazmat/primitives/padding/