From fe02a0115f06d3b317407fd0590b356bc6c972fe Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 9 Oct 2023 19:31:22 +0530 Subject: [PATCH] fix: encrypt/decrypt File methods --- pubnub/lib/src/dx/files/files.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pubnub/lib/src/dx/files/files.dart b/pubnub/lib/src/dx/files/files.dart index 04ebf305..f8baefea 100644 --- a/pubnub/lib/src/dx/files/files.dart +++ b/pubnub/lib/src/dx/files/files.dart @@ -292,8 +292,9 @@ class FileDx { List encryptFile(List bytes, {CipherKey? cipherKey, Keyset? keyset, String? using}) { keyset ??= _core.keysets[using]; - return _core.crypto - .encryptFileData((cipherKey ?? keyset.cipherKey)!, bytes); + return keyset.cipherKey == _core.keysets.defaultKeyset.cipherKey + ? _core.crypto.encrypt(bytes) + : _core.crypto.encryptFileData(keyset.cipherKey!, bytes); } /// Decrypts file content in bytes format. @@ -306,7 +307,8 @@ class FileDx { List decryptFile(List bytes, {CipherKey? cipherKey, Keyset? keyset, String? using}) { keyset ??= _core.keysets[using]; - return _core.crypto - .decryptFileData((cipherKey ?? keyset.cipherKey)!, bytes); + return keyset.cipherKey == _core.keysets.defaultKeyset.cipherKey + ? _core.crypto.decrypt(bytes) + : _core.crypto.decryptFileData(keyset.cipherKey!, bytes); } }