mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-19 21:44:30 -04:00
imported signalr 1.1.3 into NzbDrone.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNet.SignalR.Infrastructure
|
||||
{
|
||||
public class DefaultProtectedData : IProtectedData
|
||||
{
|
||||
private static readonly UTF8Encoding _encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
|
||||
|
||||
public string Protect(string data, string purpose)
|
||||
{
|
||||
byte[] purposeBytes = _encoding.GetBytes(purpose);
|
||||
|
||||
byte[] unprotectedBytes = _encoding.GetBytes(data);
|
||||
|
||||
byte[] protectedBytes = ProtectedData.Protect(unprotectedBytes, purposeBytes, DataProtectionScope.CurrentUser);
|
||||
|
||||
return Convert.ToBase64String(protectedBytes);
|
||||
}
|
||||
|
||||
public string Unprotect(string protectedValue, string purpose)
|
||||
{
|
||||
byte[] purposeBytes = _encoding.GetBytes(purpose);
|
||||
|
||||
byte[] protectedBytes = Convert.FromBase64String(protectedValue);
|
||||
|
||||
byte[] unprotectedBytes = ProtectedData.Unprotect(protectedBytes, purposeBytes, DataProtectionScope.CurrentUser);
|
||||
|
||||
return _encoding.GetString(unprotectedBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user