getEncryptionOptions method
Retrieves encryption options from secure storage.
The keyName
parameter can be used to specify a custom name for the key.
If not provided, a default name will be used.
Returns the encryption options, or null
if no key is found.
Implementation
Future<EncryptionOptions?> getEncryptionOptions({
String? keyName,
}) async {
final effectiveKeyName = keyName ?? _defaultKeyName;
final key = await _secureStorage.read(key: _getKey(effectiveKeyName));
if (key == null) {
_log.warning('No encryption key found: $effectiveKeyName');
return null;
}
// Currently only AES-256 is supported
EncryptionAlgorithm algorithm = EncryptionAlgorithm.aes256;
return EncryptionOptions(
algorithm: algorithm,
key: key,
);
}