Skip to content

Commit

Permalink
fix: encrypt/decrypt File methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Oct 9, 2023
1 parent 9c6edc2 commit fe02a01
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pubnub/lib/src/dx/files/files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ class FileDx {
List<int> encryptFile(List<int> 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.
Expand All @@ -306,7 +307,8 @@ class FileDx {
List<int> decryptFile(List<int> 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);
}
}

0 comments on commit fe02a01

Please sign in to comment.