Search code examples
c#neventstore

NEventStore - decrypt and deserialize stared event data


I'm trying NEventStore. I started example project and I created some events and saved to database. But in database I see encrypted data only and I cant identify correctness of my stored events. I tried to turn off all settings about encryption but nothing changed.

My init code :

var init = Wireup.Init()
                         .LogToOutputWindow()
                         .UsingInMemoryPersistence()
                         .UsingSqlPersistence("EventStore") // Connection string is in app.config
                         .WithDialect(new MsSqlDialect())
                         .EnlistInAmbientTransaction() // two-phase commit
                         .InitializeStorageEngine()
                         .TrackPerformanceInstance("example")
                         .UsingJsonSerialization()
                         //.Compress()
                         //.EncryptWith(EncryptionKey)
                         .HookIntoPipelineUsing(new[] {new AuthorizationPipelineHook()})
                         .UsingSynchronousDispatchScheduler()
                         .DispatchTo(new DelegateMessageDispatcher(DispatchCommit))
                         .Build();

I tried to do it in SQL with casting varbinary to varchar by cast([Payload] as varchar(max) but I didn't receive clean data as well.

How I can read NEventStore data in readable form please?


Solution

  • You can cast Payload column to XML:

    SELECT TOP 10 CAST(Payload AS XML), *
      FROM [dbo].[Commits]
    

    Even though the payload is actually JSON, I get the correct result, e.g.

    [{"Headers":{},"Body":"Test"}]
    

    Obviously, that does not work for compressed or encrypted data.