mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 17:51:45 +08:00
26 lines
798 B
C#
26 lines
798 B
C#
using System.Web.Security;
|
|
using Microsoft.Owin.Security.DataProtection;
|
|
|
|
namespace Orchard.OpenId.Security {
|
|
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);
|
|
}
|
|
}
|
|
} |