read method

Future<String?> read(
  1. String key
)

读取并解密指定键的数据

如果启用了单向加密,则会抛出异常(无法解密)

Implementation

Future<String?> read(String key) async {
  final encrypted = await storage.read(key: key);
  if (encrypted == null) return null;

  if (isOneWayEncryption == true) {
    throw Exception("One-way encryption is enabled. Cannot decrypt.");
  }

  final decrypted = cipher(encrypted, passphrase!.length, decrypt: true);

  debugPrint('SecuredStorage [READ] $key: $decrypted');
  return decrypted;
}