How iktakahiro/fargon2 works
1. What this repository is
- fargon2 is a Flutter plugin package, not a standalone app.
- Its purpose is to expose Argon2 password hashing to Dart code while executing the actual hashing natively on Android and iOS.
2. Public API boundary
- The main package surface is lib/fargon2.dart.
- That Dart layer is the only code consumers are meant to call directly; the README example shows creating a Fargon2 instance and calling hash(...).
3. Cross-platform execution model
- The architecture is split into three layers:
- Dart API in Flutter
- Native platform plugin code
- Platform-specific hashing implementation
- Data flows from Dart inputs such as passphrase, salt, mode, and tuning parameters into native code, and the computed hash string returns back to Dart.
4. Android subsystem
- Android implementation lives under android/.
- The plugin entrypoint is android/src/main/kotlin/dev/iktakahiro/fargon2/Fargon2Plugin.kt.
- This is the Android boundary where Flutter method calls are received and forwarded into the native hashing logic.
5. iOS subsystem
- iOS implementation lives under ios/.
- The plugin code is split across ios/Classes/Fargon2Plugin.h, ios/Classes/Fargon2Plugin.m, and ios/Classes/SwiftFargon2Plugin.swift.
- This suggests an iOS plugin boundary with a Swift implementation plus Objective-C compatibility/registration glue.
6. Hashing domain
- The core domain concept is Argon2 hashing, with support for the Argon2 variants mentioned in the README: argon2id, argon2i, and argon2d.
- The plugin accepts Argon2 cost parameters such as hash length, iterations, parallelism, and memory size, which are central to the runtime behavior and output.
7. Platform-native dependency boundary
- The repository is a wrapper around platform-native Argon2-capable libraries rather than implementing the algorithm entirely in Dart.
- The README credits CatCrypto and argon2kt, indicating the real hashing work is delegated to native dependencies or their equivalents under the hood.
8. Example application
- example/ is a full Flutter app used to demonstrate and validate the plugin on both platforms.
- It contains its own Android and iOS host projects plus example/lib/main.dart and a widget test, so it serves as the integration reference for consumers.
9. Testing and CI
- Repository-level tests live in test/fargon2_test.dart.
- GitHub Actions workflow /.github/workflows/test.yaml runs Flutter tests, making the CI boundary focused on package validation rather than deployment.
10. Build and packaging structure
- pubspec.yaml, analysis_options.yaml, and .fvm/fvm_config.json define the Dart/Flutter toolchain and style constraints.
- Android and iOS subprojects are configured as plugin host builds, with Gradle and CocoaPods metadata present in each platform folder.
11. Platform integration details
- The plugin is packaged for Android with Gradle files and an AndroidManifest.xml, and for iOS with a .podspec, Xcode project files, and Flutter xcconfig assets.
- This is the standard Flutter plugin layout for shipping one Dart package with two native implementations.
12. Operationally important diagram view
- If you draw the architecture, the main arrow should be: Flutter app code → fargon2 Dart API → Android/iOS plugin layer → Argon2 native implementation → hashed result back to Dart.
- The example app is a separate consumer of that same path, and CI/test files validate the package boundary.
Main entry points: fargon2.dart Fargon2 API · Fargon2Plugin.kt Android bridge · SwiftFargon2Plugin.swift iOS bridge · Fargon2Plugin.m iOS glue
Components 18
Dart package
Public Flutter-facing API and package metadata
- Fargon2 API · Main Dart entrypoint exposed to consumers
lib/fargon2.dart - Package spec · Flutter plugin package declaration and dependency wiring
pubspec.yaml - README · Public usage examples and platform notes
README.md
Android plugin
Android host integration and native bridge
- Android bridge · Receives Flutter calls on Android and forwards them natively
android/src/main/kotlin/dev/iktakahiro/fargon2/Fargon2Plugin.kt - Android manifest · Android plugin registration and host metadata
android/src/main/AndroidManifest.xml - Android build · Android plugin build and packaging configuration
android/build.gradle
iOS plugin
iOS host integration and native bridge
- iOS bridge · Swift-side Flutter plugin implementation
ios/Classes/SwiftFargon2Plugin.swift - iOS glue · Objective-C registration and compatibility layer
ios/Classes/Fargon2Plugin.m - iOS header · Public native interface for the iOS plugin target
ios/Classes/Fargon2Plugin.h - Podspec · iOS plugin packaging and dependency metadata
ios/fargon2.podspec
Example app
Integration sample that exercises the plugin
- Example app · Sample consumer app demonstrating plugin use
example/lib/main.dart - Example Android · Android host project for the sample app
example/android/app/build.gradle - Example iOS · iOS host project for the sample app
example/ios/Podfile - MainActivity · Android launcher activity for the sample
example/android/app/src/main/kotlin/dev/iktakahiro/fargon2_example/MainActivity.kt - AppDelegate · iOS application delegate for the sample
example/ios/Runner/AppDelegate.swift
Quality and release
Tests, CI, and toolchain configuration
- Package tests · Repository-level validation of the Dart surface
test/fargon2_test.dart - CI workflow · Automated Flutter test execution on push/PR
.github/workflows/test.yaml - Tooling · Analyzer, Flutter version, and package tooling constraints
analysis_options.yaml
Connections 19
- README → Fargon2 API: documents · README shows the intended consumer-facing API
- Package spec → Fargon2 API: exposes · Package metadata publishes the Dart entrypoint
- Fargon2 API → Android bridge: calls · Dart API forwards hashing requests to Android
- Fargon2 API → iOS bridge: calls · Dart API forwards hashing requests to iOS
- Android bridge → Android manifest: registered by · Android plugin is surfaced through the platform manifest
- Android bridge → Android build: built with · Android bridge is packaged by the Gradle plugin build
- Android bridge → Fargon2 API: returns hash · Native result flows back through the Dart boundary
- iOS bridge → iOS glue: bridged by · Swift plugin is exposed through Objective-C glue
- iOS glue → iOS header: declares · Objective-C layer exposes the native plugin interface
- iOS bridge → Podspec: packaged by · iOS bridge is distributed as a CocoaPods plugin
- iOS bridge → Fargon2 API: returns hash · Native result flows back through the Dart boundary
- Example app → Fargon2 API: uses · Sample app consumes the public Dart API
- MainActivity → Android bridge: hosts · Example Android app loads the Android plugin path
- AppDelegate → iOS bridge: hosts · Example iOS app loads the iOS plugin path
- Example Android → MainActivity: builds · Android sample project builds the launcher activity
- Example iOS → AppDelegate: builds · iOS sample project builds the app delegate
- Package tests → Fargon2 API: validates · Repository tests exercise the Dart API boundary
- CI workflow → Package tests: runs · GitHub Actions executes the test suite
- Tooling → Fargon2 API: constrains · Analyzer and Flutter tool versions shape the package surface