Skip to main content

A modular Python implementation of AES featuring customizable transformations and comprehensive JSON dataflow logging for cryptographic analysis.

Project description

Warning: This implementation is intended for analysis and educational purpose and should not be used for real-world security.

About

  • Author: shrimp2845
  • Version: 0.4.2
  • License: MIT

A pure Python implementation of the Advanced Encryption Standard (AES) algorithm with support for multiple key sizes, configurable internal transformations, detailed logging, and multiple cipher modes of operation.

Features

  • AES-128/AES-192/AES-256 support
  • ECB/CBC/CTR modes
  • PKCS#7 padding
  • Custom AES transformation configuration
  • Custom S-Box support
  • Encryption/decryption logging

Project Structure


project_AES/
  ├── __init__.py
  ├── block_utils.py
  ├── configs.py
  ├── project_AES.py
  └── aes_core/
      ├── __init__.py
      ├── cipher.py
      ├── core_utils.py
      ├── key_expansion.py
      ├── math_utils.py
      └── round.py

Installation

Requires Python 3.10+

pip install project-aes

or

pip install tqdm
git clone https://github.com/shrimp2845-tw/project_AES.git
cd project_AES

Quick Start

from project_AES import AES
key = b"0123456789abcdef"
plaintext = b"hello world"
cipher = AES(key)
ciphertext = cipher.encrypt(plaintext)
print(ciphertext)

Docs

class initialize
----------------------
from project_AES import AES
aes = AES(key, mode='ECB', config=None)

key -> bytes (16, 24 or 32 bytes)
Required. AES key for 128/192/256-bit encryption.
mode -> str (optional)
Block cipher mode of operation.
Supported: 'ECB', 'CBC', 'CTR'
Default: 'ECB'
config -> AESConfig (optional)
Advanced configuration. Default is AESConfig()


methods
----------------------
encrypt(data: bytes) -> bytes
decrypt(data: bytes) -> bytes
→ Encrypt/decrypt bytes data

encrypt_block(block: bytes) -> bytes
decrypt_block(block: bytes) -> bytes
→ single block (16 bytes) encryption/decryption

Examples

This project includes three example scripts demonstrating different functionalities of the module:

​1.File Cipher: A script for encrypting and decrypting files using AES with various operation modes (ECB, CBC, CTR).

​2.Avalanche Observation: A script to observe the avalanche effect by testing how bit-flips in plaintext affect the ciphertext under different configurations.

3.Differential: A script constructs Difference Distribution Tables (DDT) to analyze the cryptographic strength of the S-Box (both standard and user defined).

Samples

1.File Cipher:

You can try to decrypt these examples by your self

  • hina.png -> encrypt(key=gehenna, mode=ECB) -> hina.bin

  • kayoko.jpg -> encrypt(key=cat, mode=CBC) -> kayoko.bin

  • r18.gif -> encrypt(key=give you up, mode=CTR) -> r18.bin

(I originally wanted to use a picture of Shiina Mahiru, but I couldn’t find any good images under a cc license QAQ)

2.Avalanche Observation:

Alt-text

Disclaimer

This implementation is intended for analysis and educational purposes only.
It does not guarantee cryptographic security or production-level performance efficiency.

Do not use this project in any environment that requires strong security assurances.

License

Source code: MIT License

Example assets: Some materials under /examples/test_files are used for demonstration purposes only and remain under their original license:

© SeriBaKa (https://www.deviantart.com/seribaka/art/Blue-archive-sorasaki-hina-905973822)

© らんどう(https://www.pixiv.net/artworks/116363500)

Thanks to the original creators 🤎

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

project_aes-0.4.2.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

project_aes-0.4.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file project_aes-0.4.2.tar.gz.

File metadata

  • Download URL: project_aes-0.4.2.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for project_aes-0.4.2.tar.gz
Algorithm Hash digest
SHA256 b1b81572c2a63ad889a0fb49244d5a1f57a8767593d5367a7b0906bbc7e4632b
MD5 186a33747d21daa22548a9b1971fd5c1
BLAKE2b-256 c61ba05836838508e39f76bf23c9a012a5244168df3ae947158da6665cd620d2

See more details on using hashes here.

File details

Details for the file project_aes-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: project_aes-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for project_aes-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 62f8dd3035a93e1fc100050195d08a9fea96ecdb29f23c988b6f35df3b9c3f86
MD5 31c466a2f635c998af61f3aef153cd68
BLAKE2b-256 6e98d6f5ed361d6be7c6df808d1d380b7a81d393bef7ff64f5c905addcf42bc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page