18 lines
581 B
Dart
18 lines
581 B
Dart
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
class CryptoService {
|
|
static const String _deviceIdPref = 'device_uuid';
|
|
static const _storage = FlutterSecureStorage();
|
|
|
|
/// Get or create a persistent device UUID for server-side session tracking.
|
|
static Future<String> getDeviceId() async {
|
|
final existing = await _storage.read(key: _deviceIdPref);
|
|
if (existing != null) return existing;
|
|
|
|
final newId = const Uuid().v4();
|
|
await _storage.write(key: _deviceIdPref, value: newId);
|
|
return newId;
|
|
}
|
|
}
|