Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​AspNetCore.​DataProtection.​DataProtectionCommonExtensions

Assembly: Microsoft.AspNetCore.DataProtection.Abstractions

Inheritance: object → DataProtectionCommonExtensions

Helpful extension methods for data protection APIs.

Methods

public static IDataProtector
CreateProtector​(IDataProtectionProvider provider, System.​Collections.​Generic.​IEnumerable<​string> purposes)
Creates an <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> given a list of purposes.
Returns An <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> tied to the provided purpose chain.
provider The <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> from which to generate the purpose chain.
purposes The list of purposes which contribute to the purpose chain. This list must contain at least one element, and it may not contain null elements.
Remarks This is a convenience method which chains together several calls to <see cref="M:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider.CreateProtector(System.String)" /> . See that method's documentation for more information.
public static IDataProtector
CreateProtector​(IDataProtectionProvider provider, string purpose, string[] subPurposes)
Creates an <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> given a list of purposes.
Returns An <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> tied to the provided purpose chain.
provider The <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> from which to generate the purpose chain.
purpose The primary purpose used to create the <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> .
subPurposes An optional list of secondary purposes which contribute to the purpose chain. If this list is provided it cannot contain null elements.
Remarks This is a convenience method which chains together several calls to <see cref="M:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider.CreateProtector(System.String)" /> . See that method's documentation for more information.
public static IDataProtectionProvider
GetDataProtectionProvider​(System.​IServiceProvider services)
Retrieves an <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> from an <see cref="T:System.IServiceProvider" /> .
Returns An <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> . This method is guaranteed never to return null.
services The service provider from which to retrieve the <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> .
public static IDataProtector
GetDataProtector​(System.​IServiceProvider services, System.​Collections.​Generic.​IEnumerable<​string> purposes)
Retrieves an <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> from an <see cref="T:System.IServiceProvider" /> given a list of purposes.
Returns An <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> tied to the provided purpose chain.
services An <see cref="T:System.IServiceProvider" /> which contains the <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> from which to generate the purpose chain.
purposes The list of purposes which contribute to the purpose chain. This list must contain at least one element, and it may not contain null elements.
Remarks This is a convenience method which calls <see cref="M:Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.GetDataProtectionProvider(System.IServiceProvider)" /> then <see cref="M:Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.CreateProtector(Microsoft.AspNetCore.DataProtection.IDataProtectionProvider,System.Collections.Generic.IEnumerable{System.String})" /> . See those methods' documentation for more information.
public static IDataProtector
GetDataProtector​(System.​IServiceProvider services, string purpose, string[] subPurposes)
Retrieves an <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> from an <see cref="T:System.IServiceProvider" /> given a list of purposes.
Returns An <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> tied to the provided purpose chain.
services An <see cref="T:System.IServiceProvider" /> which contains the <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" /> from which to generate the purpose chain.
purpose The primary purpose used to create the <see cref="T:Microsoft.AspNetCore.DataProtection.IDataProtector" /> .
subPurposes An optional list of secondary purposes which contribute to the purpose chain. If this list is provided it cannot contain null elements.
Remarks This is a convenience method which calls <see cref="M:Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.GetDataProtectionProvider(System.IServiceProvider)" /> then <see cref="M:Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.CreateProtector(Microsoft.AspNetCore.DataProtection.IDataProtectionProvider,System.String,System.String[])" /> . See those methods' documentation for more information.
public static string
Protect​(IDataProtector protector, string plaintext)
Cryptographically protects a piece of plaintext data.
Returns The protected form of the plaintext data.
protector The data protector to use for this operation.
plaintext The plaintext data to protect.
public static string
Unprotect​(IDataProtector protector, string protectedData)
Cryptographically unprotects a piece of protected data.
Returns The plaintext form of the protected data.
protector The data protector to use for this operation.
protectedData The protected data to unprotect.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object