| Main |
|---|
![]() |
AES-256-GCM Text Encryption Tool (Android) is a lightweight Android application built with Kotlin, 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 on decryption — making it extremely easy to use.
Developed by BI3BJU, this open-source project is ideal for personal privacy protection, password management assistance, and more.
- ✅ 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 a system-secure RNG and auto-copies to clipboard
- 📋 Automatic clipboard integration – results are copied to clipboard after encryption/decryption
- 🔄 Output format switch – choose Base64 or Hex for encryption
- 🔍 Auto-detection of ciphertext format – no need to select Base64 or Hex manually when decrypting
- 📊 Real-time statistics – shows UTF-8 byte count of plaintext and ciphertext length (characters for Base64, bytes for Hex) based on current format
- 🖱️ Long-press context menu – supports copy, paste, cut, select all, clear, and quick actions: Encrypt current / Decrypt current / Generate key
- 🛡️ Error-aware decryption – shows friendly messages for wrong keys or corrupted data
- 🌐 Cross-platform interoperability – compatible with the Python desktop client
- Android Studio (latest stable)
- JDK 11+
- Android SDK (API 26+ for
PBKDF2WithHmacSHA256)
Note:
SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256")requires Android API 26+. If you must support lower API levels, enable core library desugaring inapp/build.gradle.
- Clone the repository:
git clone https://github.com/BI3BJU/Text-Encryption-Tool-Java.git - Open the project in Android Studio.
- Run it on an emulator or a physical device.
-
Key
- Enter any arbitrary text (e.g., a passphrase); the app derives a 32-byte key using PBKDF2-HMAC-SHA256 (600,000 iterations) with a random salt.
- It is highly recommended to tap Generate Key to obtain a high-entropy Base64 random key and store it securely.
-
Encryption
- Type your plaintext in the Plain Text field.
- Choose output format: Base64 or Hex.
- Tap Encrypt – the ciphertext appears in the Cipher Text field and is automatically copied to the clipboard.
- Ciphertext length statistics update accordingly.
-
Decryption
- Paste the ciphertext (Base64 or Hex, automatically detected) into the Cipher Text field.
- Ensure the correct key is entered.
- Tap Decrypt – upon success, the plaintext is displayed and copied to the clipboard.
-
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.
-
Context menu
- Long-press inside any text field to open a context menu for copy, paste, cut, select all, clear, and quick encryption/decryption/key-generation actions.
- 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 Generate Key, rather than a simple password.
- Salt: A fresh 16-byte salt is generated for every encryption using
SecureRandom. Salt is not secret and is transmitted alongside the ciphertext. - Nonce: A fresh 12-byte nonce is generated for each encryption using
SecureRandom, ensuring that identical plaintexts yield different ciphertexts. - Data safety: The key exists only in memory; the app 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.
- Language: Kotlin
- Cryptography: Java Cryptography Extension (JCE) –
AES/GCM/NoPadding - Key Derivation: PBKDF2-HMAC-SHA256 via
SecretKeyFactory+PBEKeySpec(600,000 iterations) - Encoding:
Base64and custom Hex converter - UI: Android XML layouts with
AppCompatandWindowInsetshandling
app/src/main/java/...— Kotlin source codeapp/src/main/res/layout/...— Android XML layoutsapp/src/main/res/values/...— strings and theme resourcesbuild.gradle(.kts)— build configurationREADME.md— this documentationLICENSE— MIT License
- v1.1 – 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 – First stable release with AES-256-GCM encryption/decryption, Base64/Hex output, clipboard integration, real-time statistics, long-press context menu, and cross-platform interoperability.
BI3BJU – Amateur radio enthusiast & open-source developer
This project is licensed under the MIT License – see the LICENSE file for details.
The Android client provided in this project and the Python client (https://github.com/BI3BJU/Text-Encryption-Tool-Python) 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.
Both implementations strictly adhere to the following mathematical and cryptographic specifications during encryption and decryption:
- 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-8byte stream, combined with the salt, and derived into a fixed 32-byte (256-bit) strong key for AES. - Encryption Algorithm:
Uses the industry-standard AES-256-GCM authenticated encryption mode (configured with
NoPaddingand a 128-bit / 16-byte authentication tag). - 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.urandomand Android'sSecureRandom). The salt ensures that the same password produces different keys for different messages, defeating precomputed rainbow tables. - 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.
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.
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...)
This app is provided as-is for experimental and educational purposes. The author is not responsible for any misuse or damage caused by this software.
