A simple Python script to generate a random AES key of a given length.
- Generate a key of 8, 16, 32 or 64 bytes.
- Output the key to the console in hexadecimal format.
- Saving the key to a file (if necessary).
- Python 3.6 or higher.
- Modules from the standard library:
argparse,secrets.
-
Clone the repository:
git clone https://github.com/IVSamDev/AES-Key-Generator.git
-
Make sure you have Python 3.6+ installed:
python3 --version
Run the script from the console, specifying the key length and (optionally) the file to save:
python3 key.py --size <bytes> [--output <file>]| Option | Description | Commitment | Possible values |
|---|---|---|---|
-s, --size |
Key length in bytes | necessarily | 8, 16, 32, 64 |
-o, --output |
File path to save the key (hex string) | optionally | <file_name>.txt |
-
Generate a 16-byte key and output to the console:
python3 key.py -s 16
-
Generate a 32-byte key and save to the
key.txtfile:python3 key.py --size 32 --output key.txt
MIT License © IVSamDev