PubNub C# SDK provides built-in message and file encryption to secure your real-time communications. This documentation covers crypto module configuration and utility methods for encrypting and decrypting messages and files using both legacy 128-bit and enhanced 256-bit AES-CBC encryption.
For general SDK configuration and initialization, refer to the Configuration page.
ConfigurationCryptoModule
configuration
To configure the CryptoModule
to encrypt all messages/files, you can use the following methods in the C# SDK:
Your client can decrypt content encrypted using either of the modules. This way, you can interact with historical messages or messages sent from older clients while encoding new messages using the more secure 256-bit AES-CBC cipher.
Older SDK versionsApps built using the SDK versions lower than 6.18.0 will not be able to decrypt data encrypted using the 256-bit AES-CBC cipher. Make sure to update your clients or encrypt data using the legacy algorithm.
SDK Initialization requiredBefore using encryption methods, ensure your PubNub client is properly configured with publish/subscribe keys and user ID. See the Configuration guide for setup instructions.
Encryption methods EncryptThis function allows to encrypt
the data.
The cipherKey
parameter in this method is deprecated. We recommend that you configure a separate instance of the crypto module and use it for partial encryption.
If you pass cipherKey
as an argument, it overrides the crypto module configuration and the legacy encryption with 128-bit cipher key entropy is used.
To encrypt
the data you can use the following method(s) in C# SDK.
pubnub.Encrypt(inputString, cipherKey)
* required
Parameter DescriptioninputString
*
Type: String
Thedata
to encrypt
. cipherKey
Type: String
Cipher key to use for encryption. Sample code Encrypt part of message Encrypt fileThis function allow to encrypt
the file content/data.
The cipherKey
parameter in this method is deprecated. We recommend that you configure a separate instance of the crypto module and use it for partial encryption.
If you pass cipherKey
as an argument, it overrides the crypto module configuration and the legacy encryption with 128-bit cipher key entropy is used.
To encrypt
the file you can use the following method(s) in C# SDK.
pubnub.EncryptFile(sourceFile, destinationFile)
pubnub.EncryptFile(sourceFile, destinationFile, cipherKey)
* required
Parameter DescriptionsourceFile
*
Type: String
File to be encrypted.destinationFile
*
Type: String
Path of the encrypted file to be saved.cipherKey
Type: String
Cipher Key to use for encryption. If provided, the legacy encryption with 128-bit cipher key entropy is used. If not provided, theCryptoModule
from PubNub config will be used.
For more information, refer to Crypto module configuration.
This parameter is deprecated and will be removed in a future version. Please use the CryptoModule
from PubNub config instead.
byte[] outputBytes = pubnub.EncryptFile(sourceBytes) byte[] outputBytes = pubnub.EncryptFile(sourceBytes, cipherKey)
* required
Parameter DescriptionsourceBytes
*
Type: byte[]
byte array of the file.cipherKey
Type: String
Cipher Key to use for encryption. If provided, the legacy encryption with 128-bit cipher key entropy is used. If not provided, theCryptoModule
from PubNub config will be used.
For more information, refer to Crypto module configuration.
Sample code Decryption methods DecryptThis function allows to decrypt
the data.
The cipherKey
parameter in this method is deprecated. We recommend that you configure a separate instance of the crypto module and use it for partial encryption.
If you pass cipherKey
as an argument, it overrides the crypto module configuration and the legacy encryption with 128-bit cipher key entropy is used.
To decrypt
the data you can use the following method(s) in C# SDK.
pubnub.Decrypt(inputString, cipherKey)
* required
Parameter DescriptioninputString
*
Type: String
Thedata
to decrypt
. cipherKey
Type: String
Cipher key to use for encryption.This parameter is deprecated and will be removed in a future version. Please use the CryptoModule
from PubNub config instead.
This function allow to decrypt
the file content/data.
To decrypt
the file you can use the following method(s) in C# SDK.
pubnub.DecryptFile(sourceFile, destinationFile); pubnub.DecryptFile(sourceFile, destinationFile, cipherKey);
* required
Parameter DescriptionsourceFile
*
Type: String
File to be decrypted.destinationFile
*
Type: String
Path of the decrypted file to be saved.cipherKey
Type: String
Cipher Key to use for decryption. If provided, the legacy encryption with 128-bit cipher key entropy is used. If not provided, theCryptoModule
from PubNub config will be used.
For more information, refer to Crypto module configuration.
byte[] outputBytes = pubnub.DecryptFile(sourceBytes) byte[] outputBytes = pubnub.DecryptFile(sourceBytes, cipherKey)
* required
Parameter DescriptionsourceBytes
*
Type: byte[]
byte array of the file.cipherKey
Type: String
Cipher Key to use for decryption. If provided, the legacy encryption with 128-bit cipher key entropy is used. If not provided, theCryptoModule
from PubNub config will be used.
For more information, refer to Crypto module configuration.
Sample codeRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4