This repository was archived by the owner on Nov 29, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSnippets.cs
More file actions
40 lines (37 loc) · 1.15 KB
/
Snippets.cs
File metadata and controls
40 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Security.Cryptography;
using Newtonsoft.Json.Encryption;
using NServiceBus.Newtonsoft.Encryption;
// ReSharper disable UnusedParameter.Local
#pragma warning disable SYSLIB0022
class Snippets
{
void Usage(byte[] key)
{
#region NsbUsage
var configuration = new EndpointConfiguration("NServiceBusSample");
var serialization = configuration.UseSerialization<NewtonsoftJsonSerializer>();
var encryptionFactory = new EncryptionFactory();
serialization.Settings(
new()
{
ContractResolver = encryptionFactory.GetContractResolver()
});
configuration.EnableJsonEncryption(
encryptionFactory: encryptionFactory,
encryptStateBuilder: () =>
(
algorithm: new RijndaelManaged
{
Key = key
},
keyId: "1"
),
decryptStateBuilder: (keyId, initVector) =>
new RijndaelManaged
{
Key = key,
IV = initVector
});
#endregion
}
}