deserializeCombinedCipher function

ASECombinedCipher deserializeCombinedCipher(
  1. String path
)

Deserializes the combined ciphertext from a JSON file The file should contain a JSON object with the keys 'kemCt', 'nonce', 'ciphertext', and 'salt'.

Implementation

ASECombinedCipher deserializeCombinedCipher(String path) {
  if (!isPathSafe(path)) {
    throw ArgumentError('Unsafe file path');
  }

  final file = File(path);
  if (!file.existsSync()) {
    throw FileSystemException('File not found', path);
  }

  if (file.lengthSync() > 1024 * 1024) {
    throw FileSystemException('File too large', path);
  }

  return deserializeCombinedCipherFromString(file.readAsStringSync());
}