initialize method

Future<void> initialize()

Implementation

Future<void> initialize() async {
  if (autoResetKey) {
    await rotateKey();
    return;
  }

  if (providedKey != null) {
    _cachedKey = providedKey;
    await _storeKey(_cachedKey!);
    return;
  }

  final stored = await _loadKey();
  if (stored != null) {
    _cachedKey = stored;
    return;
  }

  // Auto-generate if no key exists
  await rotateKey();
}