Skip to content

About

A desktop AES-256-GCM text encryption tool developed using Python/Tkinter; it supports Base64 and hexadecimal output, features automatic ciphertext format detection, and is interoperable with the Android version. 一款使用 Python/Tkinter 开发的桌面级 AES-256-GCM 文本加密工具;它支持 Base64 和十六进制输出,具备密文格式自动检测功能,并与 Android 版本保持互操作性。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

44 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AES-256-GCM Text Encryption Tool

License Python Platform [GitHub last commit]


Screenshots

Main
Main

📖 Introduction

AES-256-GCM Text Encryption Tool is a lightweight desktop application built with Python and Tkinter, designed to securely encrypt and decrypt arbitrary Unicode text.
It uses the industry-standard AES-256-GCM authenticated encryption algorithm, derives keys with PBKDF2-HMAC-SHA256 (600,000 iterations) and a random 16-byte salt, supports both Base64 and Hex output formats, and automatically detects the encoding of input ciphertext – making it extremely easy to use.

Developed by BI3BJU, this open-source project is ideal for personal privacy protection, password management assistance, and more.

✨ Features

  • ✅ AES-256-GCM encryption – ensures confidentiality, integrity, and authenticity
  • 🔑 Strong key derivation – PBKDF2-HMAC-SHA256 with 600,000 iterations and a fresh 16-byte random salt per message
  • 🔒 Flexible key input – accepts any text passphrase (derived via PBKDF2) or a 32-byte Base64 random key (recommended)
  • 🎲 One-click random key generation – uses system-secure RNG and auto-copies to clipboard
  • 📋 Automatic clipboard integration – results are copied to clipboard after encryption/decryption
  • 🔄 Auto-detection of ciphertext format – no need to select Base64 or Hex manually when pasting; the program decodes it automatically
  • 📊 Real-time statistics – shows UTF-8 byte count of plaintext and ciphertext length (characters for Base64, bytes for Hex) based on current format
  • 🌐 Bilingual UI (English/Chinese) – switches based on system language (Windows / Linux / macOS)
  • 🖱️ Right-click context menu – supports copy, paste, cut, select all, clear for efficient editing
  • 🎨 Clean and intuitive UI – clear layout with a status bar giving real-time feedback

🚀 Quick Start

Requirements

  • Python 3.6+
  • Dependency: cryptography (Tkinter is built-in with Python)

Install dependency

Run command: pip install -r requirements.txt

Run the program

Run command: python main.py

🧩 Usage Guide

  1. Key

    • You may enter any arbitrary text (e.g., a passphrase); the program will derive a 32-byte key using PBKDF2-HMAC-SHA256 (600,000 iterations) with a random salt.
    • It is highly recommended to click the “Generate Key” button to obtain a high-entropy Base64 random key and store it securely.
    • The input field shows a placeholder hint, encouraging the use of a password manager for strong key generation.
  2. Encryption

    • Type your plaintext in the “Plaintext” area.
    • Choose output format (Base64 or Hex).
    • Click “Encrypt →” – the ciphertext will appear in the “Ciphertext” area and be automatically copied to your clipboard.
    • The ciphertext length statistics will update accordingly.
  3. Decryption

    • Paste the ciphertext (Base64 or Hex, automatically detected) into the “Ciphertext” area.
    • Ensure the correct key is entered.
    • Click “← Decrypt” – upon success, the plaintext is displayed and copied to clipboard.
  4. Real-time statistics

    • Below the plaintext area, the UTF-8 byte count is shown.
    • Below the ciphertext area, the length is displayed: characters for Base64, bytes for Hex. If the ciphertext is invalid, a warning appears.
  5. Context Menu

    • Right-click (or two-finger tap on touchpad) inside any text box to open a context menu for copy, paste, cut, select all, and clear.

🔒 Security Notes

  • Algorithm: AES-256-GCM (Galois/Counter Mode) – an authenticated encryption mode that detects tampering and wrong keys.
  • Key derivation: PBKDF2-HMAC-SHA256 with 600,000 iterations and a fresh 16-byte random salt per message. This significantly raises the cost of offline dictionary/brute-force attacks compared with a single hash. Strongly recommended: use the high-entropy Base64 key generated by the “Generate Key” button, rather than a simple password.
  • Salt: A fresh 16-byte salt is generated for every encryption using os.urandom. Salt is not secret and is transmitted alongside the ciphertext.
  • Nonce: A fresh 12-byte nonce is generated for each encryption (using os.urandom), ensuring that identical plaintexts yield different ciphertexts.
  • Data safety: The key exists only in memory; the program does not save any data to disk (unless you manually copy it out).
  • Error handling: Decryption failures show a generic “wrong key or corrupted data” message, avoiding internal state leakage.
  • Backward compatibility: v1.1 ciphertexts are NOT compatible with v1.0 (which used bare SHA-256 and no salt). Re-encrypt old messages with v1.1 if you need cross-version consistency.

🛠️ Technology Stack

  • Frontend: Tkinter (Python built-in GUI library)
  • Cryptography: AESGCM from the cryptography library, PBKDF2HMAC for key derivation
  • Encoding: Automatic Base64 / Hex detection and conversion
  • Internationalisation: System locale detection with a custom I18n singleton manager

📁 Project Structure

  • main.py — Main program
  • requirements.txt — Python dependencies
  • build.bat — Optional Windows build script
  • build.sh — Optional Linux/macOS build script
  • LICENSE — MIT License
  • .gitignore — Git ignore rules
  • README.md — This documentation

📝 Changelog

  • v1.1 (2026-11) – Switched key derivation from bare SHA-256 to PBKDF2-HMAC-SHA256 (600,000 iterations) with a 16-byte random salt per message. Ciphertext structure changed to salt(16) ‖ nonce(12) ‖ ciphertext ‖ tag(16); minimum length is now 44 bytes. Not backward compatible with v1.0.
  • v1.0 (2026-06) – First stable release with basic encryption/decryption, bilingual UI, clipboard integration, and real-time statistics.

👤 Author

BI3BJU – Amateur radio enthusiast & open-source developer

📄 License

This project is licensed under the MIT License – see the LICENSE file for details.

🌐 Cross-Platform Interoperability

The Python client provided in this project and the Java client (https://github.com/BI3BJU/Text-Encryption-Tool-Java) share a fully consistent and aligned underlying encryption architecture. This means: Ciphertext encrypted on the Python side can be directly decrypted on the Android side, and vice versa.

🔐 Core Encryption Standards

Both implementations strictly adhere to the following mathematical and cryptographic specifications during encryption and decryption:

  1. Key Derivation: Both sides use PBKDF2-HMAC-SHA256 with 600,000 iterations and a fresh 16-byte random salt per message. A user-provided password of any length is converted into a UTF-8 byte stream, combined with the salt, and derived into a fixed 32-byte (256-bit) strong key for AES.
  2. Encryption Algorithm: Uses the industry-standard AES-256-GCM authenticated encryption mode (configured with NoPadding and a 128-bit / 16-byte authentication tag).
  3. Random Salt: For every encryption operation, a fresh 16-byte Salt is generated using a system-level cryptographically secure random number generator (Python's os.urandom and Android's SecureRandom). The salt ensures that the same password produces different keys for different messages, defeating precomputed rainbow tables.
  4. Random Nonce/IV: For every encryption operation, a fresh 12-byte Nonce is generated using a system-level CSPRNG. Consequently, even if the password and plaintext remain identical, the resulting ciphertext differs every time.

📦 Ciphertext Data Structure

To ensure seamless interoperability of the binary data generated by both clients, the ciphertext undergoes strict byte concatenation prior to transmission or display. Regardless of whether the format is Base64 or Hex (hexadecimal), the structure of the unpacked raw binary byte stream is as follows:

Byte Range Data Type Purpose
0 ~ 15 (First 16 bytes) Salt Random salt for PBKDF2 key derivation; not secret, transmitted alongside ciphertext
16 ~ 27 (Next 12 bytes) Nonce (IV) Initialization Vector; ensures ciphertext uniqueness and prevents nonce reuse
28 ~ End (Remaining bytes) Ciphertext + Auth Tag The actual encrypted ciphertext followed by the 16-byte GCM authentication tag

The minimum valid blob length is therefore 44 bytes (16 salt + 12 nonce + 16 tag).

During decryption, the programs on both ends automatically slice the input to read the first 16 bytes as the Salt, the next 12 bytes as the Nonce, and the remaining bytes as the ciphertext and tag for integrity verification and decryption.


🔄 Transmission Format Support

Both programs feature a built-in ciphertext format auto-detection engine. When you copy the ciphertext for decryption, there is no need to manually select the input format; the tool automatically identifies and parses the following two encoding formats:

  • Base64 string (e.g., aBc1...==)
  • Hex / Hexadecimal string (e.g., 61626331...)

About

A desktop AES-256-GCM text encryption tool developed using Python/Tkinter; it supports Base64 and hexadecimal output, features automatic ciphertext format detection, and is interoperable with the Android version. 一款使用 Python/Tkinter 开发的桌面级 AES-256-GCM 文本加密工具;它支持 Base64 和十六进制输出,具备密文格式自动检测功能,并与 Android 版本保持互操作性。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages