initial commit

This commit is contained in:
betty2310
2026-10-20 12:45:50 +07:00
commit 5f3fb1543b
78 changed files with 2574 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
# Device Code
A tiny, fully offline Flutter app for one owner. Type a MAC address, get the
8‑digit device code for a date (today by default), copy it.
- iOS uses Cupertino widgets, Android uses Material 3 — chosen automatically
from the running platform.
- No network, no backend: the shared secret is embedded in
`lib/secret.dart` on purpose (must equal `DEVICE_CODE` in the backend's
`ApiGateway/appsettings.json`).
## Algorithm
Exact port of the backend's `DeviceController.GetDeviceCode`
(`lib/device_code.dart`):
```
raw = mac + yyyyMMdd + secret (UTF‑8, MAC hashed exactly as typed)
hash = SHA‑256(raw)
value = first 4 bytes of hash as big‑endian uint32
code = (value % 100000000) zero‑padded to 8 digits
```
The MAC field mirrors the existing web page: input is reduced to 12 hex digits,
lowercased and joined in pairs with `:` (e.g. `742584C0024A` →
`74:25:84:c0:02:4a`). Generation is enabled only when 12 hex digits are present.
## Develop
```sh
flutter pub get
flutter analyze
flutter test # 20 backend reference vectors + formatting + widget tests
```
### Android
```sh
flutter build apk --release
# -> build/app/outputs/flutter-apk/app-release.apk
```
### iOS (requires macOS + Xcode)
```sh
flutter doctor # Xcode + CocoaPods must be green
flutter devices # find your iPhone / simulator id
flutter run -d <device-id> # debug run (generates Podfile, runs pod install)
flutter build ios --release # release build, then open ios/Runner.xcworkspace to archive
flutter build ipa --release # or: archive directly for TestFlight / App Store
```
Signing: open `ios/Runner.xcworkspace` once in Xcode, select the Runner
target → *Signing & Capabilities*, and pick your team. For a personal device
without a paid account, a free Apple ID team works for 7‑day sideloading.
### Preview either look on any host
```sh
flutter run -d chrome --dart-define=PLATFORM_OVERRIDE=ios # Cupertino
flutter run -d chrome --dart-define=PLATFORM_OVERRIDE=android # Material 3
```