/// <summary> /// Serialize messages using the BSON message serializer with AES Encryption /// </summary> /// <param name="configurator"></param> /// <param name="symmetricKey">Cryptographic key for both encryption of plaintext message and decryption of ciphertext message</param> public static void UseEncryption(this IReceiveEndpointConfigurator configurator, byte[] symmetricKey) { var keyProvider = new ConstantSecureKeyProvider(symmetricKey); var streamProvider = new AesCryptoStreamProviderV2(keyProvider); configurator.UseEncryptedSerializerV2(streamProvider); }
/// <summary> /// Serialize messages using the BSON message serializer with AES Encryption /// </summary> /// <param name="configurator"></param> /// <param name="keyProvider">The custom key provider to provide the symmetric key for encryption of plaintext message and decryption of ciphertext message</param> public static void UseEncryption(this IReceiveEndpointConfigurator configurator, ISecureKeyProvider keyProvider) { var streamProvider = new AesCryptoStreamProviderV2(keyProvider); configurator.UseEncryptedSerializerV2(streamProvider); }