A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rebus-org/Rebus/wiki/Message-compression-and-encryption below:

Message compression and encryption · rebus-org/Rebus Wiki · GitHub

By default, Rebus uses the built-in JSON serializer which internally uses the excellent Newtonsoft JSON.NET.

Rebus supports automatic encryption of message bodies, which means that the contents of messages cannot easily be read by eavesdroppers. This can be useful if you're e.g. sending messages containing payroll information, or other kinds of information that should not be readily readable.

You can enable encryption by going:

Configure.With(...)
    .(...)
    .Options(o => {
        o.EnableEncryption("base 64 encoded encryption key");
    })
    .(...)

In case you forget to provide a valid key, Rebus is nice enough to generate one for you that you may copy into your configuration file and start using :) Rebus will used the built-in functionality in .NET to generate the key.

Since many serialization formats are pretty verbose, and JSON in that regard is probabably one of the most verbose formats because it includes the entire schema along with every single message, you may want to enable message compression.

In order to enable compression, you can do this:

Configure.With(...)
    .(...)
    .Options(o => {
        o.EnableCompression(512);
    })
    .(...)

in order to compress messages whose raw byte[] payload exceeds 512 bytes in length, or

Configure.With(...)
    .(...)
    .Options(o => {
        o.EnableCompression();
    })
    .(...)

in order to use the default threshold of 1024 bytes.

Encryption and compression combined

You can, of course, combine both encryption and compression, by going

Configure.With(...)
    .(...)
    .Options(o => {
        o.EnableEncryption(key);
        o.EnableCompression();
    })
    .(...)

Since encryption scrambles messages badly, Rebus will of course compress messages before they're encrypted when sending, and in reverse upon receiving them, no matter how you configure it.

The awesome Simon Cropp has provided a Rebus-compatible version of his excellent JSON encryption library, which allows for selectively encrypting nodes of JSON-serialized message objects, e.g. by attaching an [Encrypt] attribute to a property.

The library speaks for itself, so please visit the code repository, or go download the NuGet package.


RetroSearch 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