decryptFully method
Implementation
Future<ResourceTry<ByteData>> decryptFully(
ResourceTry<ByteData> data, bool isDeflated) async =>
data.mapWait((encryptedData) async {
// Decrypts the resource.
ByteData bytes = (await decrypt(encryptedData)).getOrElse((failure) =>
throw Exception("Failed to decrypt the resource: $failure"));
if (bytes.lengthInBytes == 0) {
throw Exception("Lcp.nativeDecrypt returned an empty ByteArray");
}
// Removes the padding.
bytes = bytes.buffer.asByteData(0, bytes.lengthInBytes - bytes.padding);
// If the ressource was compressed using deflate, inflates it.
if (isDeflated) {
bytes = bytes.inflate();
}
return bytes;
});