Secret Class¶
Represents a secret value stored in memory.
- Namespace
Microsoft.AspNetCore.DataProtection
- Assemblies
- Microsoft.AspNetCore.DataProtection
Syntax¶
public sealed class Secret : ISecret, IDisposable
-
class
Microsoft.AspNetCore.DataProtection.
Secret
Constructors¶
-
Secret
(Microsoft.AspNetCore.DataProtection.ISecret)¶ Creates a new Secret from another secret object.
public Secret(ISecret secret)
-
Secret
(System.ArraySegment<System.Byte>) Creates a new Secret from the provided input value, where the input value is specified as an array segment.
public Secret(ArraySegment<byte> value)
-
Secret
(System.Byte*, System.Int32) Creates a new Secret from the provided input value, where the input value is specified as a pointer to unmanaged memory.
public Secret(byte *secret, int secretLength)
-
Secret
(System.Byte[]) Creates a new Secret from the provided input value, where the input value is specified as an array.
public Secret(byte[] value)
-
Methods¶
-
Dispose
()¶ Wipes the secret from memory.
public void Dispose()
-
Random
(System.Int32)¶ Returns a Secret comprised entirely of random bytes retrieved from a cryptographically secure RNG.
Return type: Microsoft.AspNetCore.DataProtection.Secret public static Secret Random(int numBytes)
-
WriteSecretIntoBuffer
(System.ArraySegment<System.Byte>)¶ Writes the secret value to the specified buffer.
public void WriteSecretIntoBuffer(ArraySegment<byte> buffer)
-
WriteSecretIntoBuffer
(System.Byte*, System.Int32) Writes the secret value to the specified buffer.
Arguments: - buffer (System.Byte<System.Byte>*) – The buffer into which to write the secret value.
- bufferLength (System.Int32) – The size (in bytes) of the provided buffer.
public void WriteSecretIntoBuffer(byte *buffer, int bufferLength)
-
Properties¶
-
Microsoft.AspNetCore.DataProtection.Secret.
Length
¶ The length (in bytes) of the secret value.
Return type: System.Int32 public int Length { get; }
-