Utility Methods API for PubNub Dart SDK
The methods on this page are utility methods that don't fit into other categories.
Encrypt File
Description
Encrypts file content in bytes format.
Method(s)
pubnub.files.encryptFileencryptFile(
List<int> bytes,
{CipherKey? cipherKey,
Keyset? keyset,
String? using}
)
Parameter | Type | Required | Description |
---|---|---|---|
bytes | List<int> | Yes | File content in bytes. |
cipherKey | cipherKey | Optional | A cipherKey to override Keyset.cipherKey . For more information, refer to Configuration. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. |
Basic Usage
var encryptedFile = pubnub.files
.encryptFile(fileContentBytes, cipherKey: CipherKey.fromUtf8('key'));
Returns
Byte List of encrypted data.
Decrypt File
Description
Decrypts file content in bytes format.
pubnub.files.decryptFile(List<int> bytes,
{CipherKey? cipherKey,
Keyset? keyset,
String? using})
Parameter | Type | Required | Description |
---|---|---|---|
bytes | List<int> | Yes | File content in bytes. |
cipherKey | cipherKey | Optional | A cipherKey to override Keyset.cipherKey . For more information, refer to Configuration. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. |
Basic Usage
var decryptedFile = pubnub.files
.decryptFile(fileContentBytes, cipherKey: CipherKey.fromUtf8('key'));
Returns
Byte list of decrypted data.
Time
Description
This function returns the current timetoken value from the PubNub network.
Algorithm constructing the timetoken
timetoken = (Unix epoch time in seconds) * 10000000
Example of creating a timetoken for a specific time and date:
08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 10000000
timetoken = 13769616060000000
Method(s)
To fetch Time you can use the following method(s) in Dart SDK:
time()
Basic Usage
var response = await pubnub.time();
Returns
The time()
operation returns a Timetoken
which contains the following operations:
Method | Type | Description |
---|---|---|
value | int | Returns an int representation of current timetoken. |