DataProtectionAdvancedExtensions Class

Namespace
Microsoft.AspNetCore.DataProtection
Assemblies
  • Microsoft.AspNetCore.DataProtection.Extensions

Syntax

public class DataProtectionAdvancedExtensions
class Microsoft.AspNetCore.DataProtection.DataProtectionAdvancedExtensions

Methods

Protect(Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector, System.Byte[], System.TimeSpan)

Cryptographically protects a piece of plaintext data, expiring the data after the specified amount of time has elapsed.

Arguments:
Return type:

System.Byte<System.Byte>[]

Returns:

The protected form of the plaintext data.

public static byte[] Protect(this ITimeLimitedDataProtector protector, byte[] plaintext, TimeSpan lifetime)
Protect(Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector, System.String, System.DateTimeOffset)

Cryptographically protects a piece of plaintext data, expiring the data at the chosen time.

Arguments:
Return type:

System.String

Returns:

The protected form of the plaintext data.

public static string Protect(this ITimeLimitedDataProtector protector, string plaintext, DateTimeOffset expiration)
Protect(Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector, System.String, System.TimeSpan)

Cryptographically protects a piece of plaintext data, expiring the data after the specified amount of time has elapsed.

Arguments:
Return type:

System.String

Returns:

The protected form of the plaintext data.

public static string Protect(this ITimeLimitedDataProtector protector, string plaintext, TimeSpan lifetime)
ToTimeLimitedDataProtector(Microsoft.AspNetCore.DataProtection.IDataProtector)

Converts an Microsoft.AspNetCore.DataProtection.IDataProtector into an Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector so that payloads can be protected with a finite lifetime.

Arguments:protector (Microsoft.AspNetCore.DataProtection.IDataProtector) – The Microsoft.AspNetCore.DataProtection.IDataProtector to convert to a time-limited protector.
Return type:Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector
Returns:An Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector.
public static ITimeLimitedDataProtector ToTimeLimitedDataProtector(this IDataProtector protector)
Unprotect(Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector, System.String, out System.DateTimeOffset)

Cryptographically unprotects a piece of protected data.

Arguments:
  • protector (Microsoft.AspNetCore.DataProtection.ITimeLimitedDataProtector) – The protector to use.
  • protectedData (System.String) – The protected data to unprotect.
  • expiration (System.DateTimeOffset) – An ‘out’ parameter which upon a successful unprotect operation receives the expiration date of the payload.
Return type:

System.String

Returns:

The plaintext form of the protected data.

public static string Unprotect(this ITimeLimitedDataProtector protector, string protectedData, out DateTimeOffset expiration)