How sreejithes/encrypto works
Purpose and Public Entry Point
Encrypto is a Dart/Flutter security package exposing unified APIs for cryptography, password protection, JWTs, encoding, randomness, and platform-backed secret storage. Consumers import lib/encrypto.dart, which acts as the package façade and composes the feature modules under lib/.
API Facade and Service Boundaries
The public Encrypto surface delegates operations to focused domains rather than exposing platform code directly. This separates application-facing APIs from crypto implementations and storage adapters.
• lib/encrypto.dart
• lib/encryption/encryption.dart
• lib/storage/secure_storage.dart
Symmetric Encryption Pipeline
Encryption accepts plaintext and caller-supplied key material, produces an EncryptionResult, and supports AES variants and ChaCha20. Decryption consumes that result and compatible key material. AES-GCM is the intended default; AES-CBC is retained for compatibility.
• lib/encryption/aes.dart
• lib/encryption/chacha20.dart
• lib/encryption/encryption_result.dart
Asymmetric Cryptography
Separate implementations cover signing, key agreement, and RSA encryption/signature use cases. These form a distinct boundary from symmetric encryption because their key types, protocols, and failure modes differ.
• lib/asymmetric/asymmetric.dart
• lib/asymmetric/ed25519.dart
• lib/asymmetric/x25519.dart
• lib/asymmetric/rsa.dart
Integrity, Derivation, and Password Security
Hashing and HMAC provide integrity primitives; KDF implementations derive keys or password hashes. Password security is a higher-level workflow built around Argon2id hashing and verification, rather than requiring callers to manage raw KDF details.
• lib/hashing/hashing.dart
• lib/hmac/hmac.dart
• lib/kdf/argon2.dart
• lib/kdf/pbkdf2.dart
• lib/password/password_security.dart
Token, Encoding, and Security Utilities
JWT creation/verification uses the package’s crypto capabilities at the token boundary. Encoding converts binary crypto artifacts to transport/storage forms, while security utilities provide cryptographically secure randomness and constant-time equality for sensitive comparisons.
• lib/jwt/jwt.dart
• lib/encoding/encoding.dart
• lib/security/secure_random.dart
• lib/security/constant_time.dart
Platform Runtime and Persistent Secrets
The core library runs in Dart/Flutter. Secure persistence is delegated to native platform facilities—Android Keystore and iOS Keychain—through the storage abstraction, keeping secret-at-rest behavior outside general crypto APIs. The included example is a multi-platform Flutter host demonstrating package integration.
• lib/storage/secure_storage.dart
• example/lib/main.dart
• example/android/app/src/main/kotlin/com/example/encrypto_example/MainActivity.kt
• example/ios/Runner/AppDelegate.swift
Main entry points: encrypto.dart Encrypto facade · asymmetric.dart Asymmetric API · encryption.dart Encryption API · main.dart Flutter example
Components 22
Public API
- Encrypto facade · Unified consumer entry point.
lib/encrypto.dart
Cryptography
- Encryption API
lib/encryption/encryption.dart - AES · AES-GCM is the default; CBC remains for compatibility.
lib/encryption/aes.dart - ChaCha20
lib/encryption/chacha20.dart - Encryption result · Carries output consumed during decryption.
lib/encryption/encryption_result.dart - Asymmetric API
lib/asymmetric/asymmetric.dart - Ed25519
lib/asymmetric/ed25519.dart - X25519
lib/asymmetric/x25519.dart - RSA
lib/asymmetric/rsa.dart
Security Services
- Hashing
lib/hashing/hashing.dart - HMAC
lib/hmac/hmac.dart - Argon2id
lib/kdf/argon2.dart - PBKDF2
lib/kdf/pbkdf2.dart - Password security · High-level Argon2id hash and verification.
lib/password/password_security.dart - JWT · Creates and verifies signed tokens.
lib/jwt/jwt.dart - Encoding
lib/encoding/encoding.dart - Secure random
lib/security/secure_random.dart - Constant-time equality
lib/security/constant_time.dart
Platform Storage
- Secure storage · Delegates secrets at rest to native facilities.
lib/storage/secure_storage.dart - Android Keystore
example/android/app/src/main/kotlin/com/example/encrypto_example/MainActivity.kt - iOS Keychain
example/ios/Runner/AppDelegate.swift
Example Host
- Flutter example · Multi-platform package integration example.
example/lib/main.dart
Connections 23
- Encrypto facade → Encryption API: exposes
- Encrypto facade → Asymmetric API: exposes
- Encrypto facade → Password security: exposes
- Encrypto facade → JWT: exposes
- Encrypto facade → Encoding: exposes
- Encrypto facade → Secure random: exposes
- Encrypto facade → Constant-time equality: exposes
- Encrypto facade → Secure storage: exposes
- Encryption API → AES: selects cipher
- Encryption API → ChaCha20: selects cipher
- Encryption API → Encryption result: produces and consumes
- Asymmetric API → Ed25519: signing
- Asymmetric API → X25519: key agreement
- Asymmetric API → RSA: encryption and signatures
- Password security → Argon2id: hashes and verifies with
- JWT → Asymmetric API: uses signing capabilities
- JWT → HMAC: uses MAC capabilities
- HMAC → Hashing: builds on hashes
- Secure storage → Android Keystore: uses on Android
- Secure storage → iOS Keychain: uses on iOS
- Flutter example → Encrypto facade: integrates
- Flutter example → Android Keystore: host runtime
- Flutter example → iOS Keychain: host runtime