A modern Android application for text encryption, decryption, and encoding conversion built with Clean Architecture principles.
Built using the principles of Robert Martin (aka Uncle Bob) and Domain-Driven Design (DDD).
| Tool | Role |
|---|---|
| Kotlin | Primary programming language |
| Jetpack Compose | Modern declarative UI framework |
| Material Design 3 | Material You design system |
| Hilt | Dependency injection framework |
| Coroutines + Flow | Asynchronous programming and reactive streams |
| Pattern/Concept | Role |
|---|---|
| Clean Architecture | Separation of concerns across layers |
| CQRS | Command Query Responsibility Segregation |
| DDD | Domain-Driven Design principles |
| MVVM | Model-View-ViewModel pattern |
| Tool | Role |
|---|---|
| Spotless | Code formatting (ktlint) |
| Detekt | Static code analysis |
| GitLab CI / Github Actions | Continuous Integration |
- Key Generation: Generate encryption keys for AES-128, AES-192, AES-256, and ChaCha20-256 algorithms
- Text Encryption: Encrypt plain text using AES or ChaCha20 with secure random IV generation
- Text Decryption: Decrypt encrypted text with support for custom IV (Initialization Vector)
- Encoding Conversion: Convert text between UTF-8, ASCII, and BASE64 encodings
- Key Management: Save, view, and delete encryption keys locally
- Clipboard Integration: Copy encrypted/decrypted text and keys to clipboard
- Multi-language Support: Internationalization support for multiple languages
- Theme Support: Light and dark theme modes
- AES-128: Advanced Encryption Standard with 128-bit key
- AES-192: Advanced Encryption Standard with 192-bit key
- AES-256: Advanced Encryption Standard with 256-bit key
- ChaCha20-256: ChaCha20 stream cipher with 256-bit key
- UTF-8: Unicode Transformation Format
- ASCII: American Standard Code for Information Interchange
- BASE64: Base64 encoding scheme
- Android Studio Hedgehog (2023.1.1) or later
- JDK 17 or later
- Android SDK 33+ (minimum SDK version)
- Git
git clone <repository-url>
cd cryptographer
# Open in Android Studio
# Sync Gradle files
# Run the app# Debug build
./gradlew assembleDebug
# Release build
./gradlew assembleRelease
# Run tests
./gradlew test
# Code formatting
./gradlew spotlessApply
# Static analysis
./gradlew detektThe project uses Gradle's version catalog (gradle/libs.versions.toml) for dependency management.
Key configuration files:
- Build configuration:
app/build.gradle.kts - Project configuration:
build.gradle.kts - Code quality:
detekt.yml, Spotless configuration inbuild.gradle.kts
The project follows Clean Architecture with clear separation of concerns:
Location: domain/
Pure business logic with no Android dependencies.
- Entities:
Text,EncryptionKey,EncryptedText - Value Objects:
EncryptionAlgorithm,TextEncoding,ValidatedText - Services:
AesEncryptionService,ChaCha20EncryptionService,TextService - Domain Events: Base domain event infrastructure
Location: application/
Orchestrates domain logic through commands and queries (CQRS pattern).
- Commands: Key generation, encryption, decryption, encoding conversion
- Queries: Key retrieval, settings retrieval
- Views: Data transfer objects for presentation
- Error Handling: Application-specific error types
Location: infrastructure/
Adapters connecting domain to external systems.
- Key Storage: Local key persistence adapters
- Settings Storage: User preferences and settings adapters
- ID Generation: UUID-based ID generation
Location: presentation/
UI components and state management.
- Screens: Compose UI screens (
KeyGenerationScreen,EncryptionScreen,EncodingScreen) - ViewModels: State management with
StateFlow - Components: Reusable Compose UI components
- Navigation: Screen navigation logic
Presentation → Application → Domain
↓
Infrastructure
Key Principles:
- Inner layers (Domain) have no dependencies on outer layers
- Dependencies point inward toward the domain
- Business logic is isolated from frameworks and UI
Using Hilt for dependency injection:
- Application Class:
CryptographerApplicationannotated with@HiltAndroidApp - DI Module:
setup/ioc/AppModule.ktprovides domain services - ViewModels: Annotated with
@HiltViewModel - Activities: Annotated with
@AndroidEntryPoint
The project includes automated code quality checks:
- Spotless: Enforces code formatting using ktlint
- Detekt: Static code analysis for Kotlin
- GitLab CI: Automated builds and tests
# Format code
./gradlew spotlessApply
# Check formatting
./gradlew spotlessCheck
# Run static analysis
./gradlew detekt
# Run all checks
./gradlew checkInstall git hooks for pre-commit checks:
./gradlew installGitHooksThis will run Spotless and Detekt before each commit.
app/src/main/java/com/example/cryptographer/
├── domain/ # Business logic (no Android dependencies)
│ ├── text/ # Text encryption domain
│ └── common/ # Shared domain concepts
├── application/ # Use cases and orchestration (CQRS)
│ ├── commands/ # Command handlers
│ ├── queries/ # Query handlers
│ └── common/ # Shared application code
├── infrastructure/ # External adapters
│ ├── key/ # Key storage adapters
│ └── settings/ # Settings storage adapters
├── presentation/ # UI layer
│ ├── key/ # Key generation screen
│ ├── encryption/ # Encryption/decryption screen
│ ├── encoding/ # Encoding conversion screen
│ └── main/ # Main navigation
└── setup/ # Configuration and setup
├── configs/ # Theme and styling
├── i18n/ # Internationalization
└── ioc/ # Dependency injection
- Keys are currently stored using SharedPreferences (for development)
- Encryption uses secure random IV generation
- All cryptographic operations follow Android security best practices
The project includes unit tests for domain logic and use cases:
# Run all tests
./gradlew test
# Run with coverage
./gradlew test jacocoTestReportGitLab CI is configured (.gitlab-ci.yml) with the following stages:
- Validate: Code formatting and static analysis
- Test: Unit tests execution
- Build: APK generation (debug and release)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please ensure:
- Code follows the existing architecture patterns
- All tests pass
- Code is formatted with Spotless
- Detekt checks pass
- Follow Clean Architecture principles
For more details, see the documentation.
For android app UI see please here