mattmanser
mattmanser

Reputation: 5796

Non-ASP.Net equivalent of MachineKey.Protect/Unprotect

Is there a simple to use encrypt/decrypt method outside the System.Web.Security namespace that are as easy to use as MachineKey.Protect/MachineKey.Unprotect()?

Or does anyone know if you can set up this outside ASP.Net as my quick trial showed that it seemed to generate a new key or something in between app restarts meaning you couldn't decrypt anything between restarts of the app.

I can roll my own using the appropriate classes, I was just wondering if they'd finally provided a simpler API?

Upvotes: 2

Views: 1383

Answers (2)

spender
spender

Reputation: 120450

The MachineKey in asp.net is autogenerated every time it starts up. To get around this you can set the MachineKey explicitly.

Of course, if the process is running on the same machine as your potential hacker, it's all a bit pointless.

Upvotes: 1

Jim
Jim

Reputation: 1735

I was searching for this as well. And after spent a few hours digging around, I found System.Security.Cryptography.ProtectedData. The usage is very similar, just that you need to provide the scope. And here's the best part: it's available from .NET 2.0.

Hope this helps someone someday.

Upvotes: 3

Related Questions