O'Reilly logo

Learning NServiceBus by David Boike

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Property encryption

If you want to encrypt an entire message, a message mutator is your best bet. However if you only want to encrypt certain properties within a message, you have another option:

public class MessageWithASecretCmd : ICommand
{
  public string ClearText { get; set; }
  public WireEncryptedString SecretText { get; set; }
}

Or if you'd like to use unobtrusive mode conventions:

public class MessageWithASecretCmd
{
  public string ClearText { get; set; }
  public string SecretTextEncrypted { get; set; }
}

// Convention Definition
Configure.Instance
 .DefiningEncryptedPropertiesAs(pi => pi.Name.EndsWith("Encrypted"));

In order to use property encryption, we will also need to enable it for the endpoint and configure the encryption key in the App.config ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required