Overview
This prompt aims to guide developers in creating a Python program for AES-256 encryption while visualizing internal state transformations. Programmers and learners will benefit by enhancing their understanding of encryption processes and the PyCryptodome library.
Prompt Overview
Purpose: The program encrypts plaintext using AES-256, demonstrating key transformations during the encryption process.
Audience: This program is aimed at developers and learners interested in understanding AES encryption mechanics.
Distinctive Feature: It visually displays internal AES state matrices at key transformation steps for educational purposes.
Outcome: Users will gain insights into AES-256 encryption and see how data transforms through each stage.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Cryptocurrency & Blockchain, Development Tools & DevOps, Productivity & Workflow
- Techniques: Zero-Shot Prompting
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
Create a Python program that performs AES-256 encryption using the PyCryptodome library.
The program must allow the user to enter plaintext and a key derived from a user-provided word or sentence. Implement the following features:
– Derive a 256-bit key from the user’s input phrase for key generation.
– Encrypt the plaintext using AES-256.
– Extract and display the internal AES state matrices at two points:
– The initial AddRoundKey step matrix
– The final AddRoundKey step matrix after all rounds
– Additionally, display the following matrices from the first round for demonstration purposes:
– SubBytes matrix
– ShiftRows matrix
– MixColumns matrix
Ensure the program outputs these matrices in a clear and readable format, illustrating the state transformations during encryption.
# Steps
1. Accept plaintext input from the user.
2. Accept a word or sentence input from the user and derive a 256-bit AES key from it (e.g., using a hash function).
3. Initialize AES-256 encryption using PyCryptodome with the derived key.
4. Perform encryption of the plaintext, capturing the state matrices after:
– Initial AddRoundKey
– SubBytes
– ShiftRows
– MixColumns
– Final AddRoundKey
5. Display:
– The initial AddRoundKey matrix
– The final AddRoundKey matrix
– For the first round, show only SubBytes, ShiftRows, and MixColumns matrices.
# Output Format
– Display the state matrices as 4×4 hexadecimal byte matrices representing the AES state.
– Clearly label each matrix, for example:
– “Initial AddRoundKey Matrix”
– “SubBytes Matrix”
– “ShiftRows Matrix”
– “MixColumns Matrix”
– “Final AddRoundKey Matrix”
– Include the input plaintext and derived key (formatted in hex) for reference.
# Notes
– Use the PyCryptodome AES module but implement or intercept the internal AES transformation steps manually or by extending the library, as PyCryptodome does not directly expose intermediate states.
– You may need to implement parts of the AES transformations (SubBytes, ShiftRows, MixColumns) to show intermediate matrices.
– Ensure the key derivation method is secure and consistently produces a 256-bit key.
Ensure that the program demonstrates the internal AES encryption transformations clearly and correctly according to the AES-256 specification using Python and PyCryptodome.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Open your Python development environment.
- Install the PyCryptodome library using pip.
- Paste the prompt into your code editor.
- Implement the steps to create the AES-256 program.
- Run the program and test with sample inputs.
Tips for Best Results
- Key Derivation: Use a secure hash function like SHA-256 to derive a 256-bit key from the user’s input phrase.
- AES Initialization: Initialize AES-256 encryption with the derived key using the PyCryptodome library.
- Matrix Display: Implement functions to display the state matrices in a clear 4×4 hexadecimal format after each transformation step.
- Transformation Implementation: Manually implement the SubBytes, ShiftRows, and MixColumns transformations to capture and show the intermediate states during encryption.
FAQ
- What is AES-256 encryption?
AES-256 is a symmetric encryption algorithm that uses a 256-bit key for secure data encryption. - How do you derive a 256-bit key from a phrase?
You can use a hash function like SHA-256 to convert the phrase into a 256-bit key. - What are the main steps in AES encryption?
AES encryption involves key expansion, initial round, main rounds, and final round with transformations. - What matrices are displayed during AES encryption?
The initial AddRoundKey, SubBytes, ShiftRows, MixColumns, and final AddRoundKey matrices are displayed.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


