Created
October 8, 2015 00:52
-
-
Save phillipsj/aa374e21ab5bc9b0ea54 to your computer and use it in GitHub Desktop.
MachineKeyDataProtector Implementation from StackOverflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MachineKeyProtectionProvider : IDataProtectionProvider | |
{ | |
public IDataProtector Create(params string[] purposes) | |
{ | |
return new MachineKeyDataProtector(purposes); | |
} | |
} | |
public class MachineKeyDataProtector : IDataProtector | |
{ | |
private readonly string[] _purposes; | |
public MachineKeyDataProtector(string[] purposes) | |
{ | |
_purposes = purposes; | |
} | |
public byte[] Protect(byte[] userData) | |
{ | |
return MachineKey.Protect(userData, _purposes); | |
} | |
public byte[] Unprotect(byte[] protectedData) | |
{ | |
return MachineKey.Unprotect(protectedData, _purposes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment