Прочитај на енглеском Уреди

Делите путем


AesGcm Constructors

Definition

Overloads

AesGcm(Byte[])
Obsolete.

Initializes a new instance of the AesGcm class with a provided key.

AesGcm(ReadOnlySpan<Byte>)
Obsolete.

Initializes a new instance of the AesGcm class with a provided key.

AesGcm(Byte[], Int32)

Initializes a new instance of the AesGcm class with a provided key and required tag size.

AesGcm(ReadOnlySpan<Byte>, Int32)

Initializes a new instance of the AesGcm class with a provided key and required tag size.

AesGcm(Byte[])

Source:
AesGcm.cs
Source:
AesGcm.cs
Source:
AesGcm.cs

Caution

AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.

Initializes a new instance of the AesGcm class with a provided key.

C#
[System.Obsolete("AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.", DiagnosticId="SYSLIB0053", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public AesGcm(byte[] key);
C#
public AesGcm(byte[] key);

Parameters

key
Byte[]

The secret key to use for this instance.

Attributes

Exceptions

The key parameter is null.

The key parameter length is other than 16, 24, or 32 bytes (128, 192, or 256 bits).

Applies to

.NET 10 и друге верзије
Производ Верзије (Застарело)
.NET Core 3.0, Core 3.1, 5, 6, 7 (8, 9, 10)
.NET Standard 2.1

AesGcm(ReadOnlySpan<Byte>)

Source:
AesGcm.cs
Source:
AesGcm.cs
Source:
AesGcm.cs

Caution

AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.

Initializes a new instance of the AesGcm class with a provided key.

C#
[System.Obsolete("AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.", DiagnosticId="SYSLIB0053", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public AesGcm(ReadOnlySpan<byte> key);
C#
public AesGcm(ReadOnlySpan<byte> key);

Parameters

key
ReadOnlySpan<Byte>

The secret key to use for this instance.

Attributes

Exceptions

The key parameter length is other than 16, 24, or 32 bytes (128, 192, or 256 bits).

Applies to

.NET 10 и друге верзије
Производ Верзије (Застарело)
.NET Core 3.0, Core 3.1, 5, 6, 7 (8, 9, 10)
.NET Standard 2.1

AesGcm(Byte[], Int32)

Source:
AesGcm.cs
Source:
AesGcm.cs

Initializes a new instance of the AesGcm class with a provided key and required tag size.

C#
public AesGcm(byte[] key, int tagSizeInBytes);

Parameters

key
Byte[]

The secret key to use for this instance.

tagSizeInBytes
Int32

The size of the tag, in bytes, that encryption and decryption must use.

Exceptions

The key parameter is null.

The key parameter length is other than 16, 24, or 32 bytes (128, 192, or 256 bits).

The tagSizeInBytes parameter is an unsupported tag size indicated by TagByteSizes.

The current platform does not support AES-GCM.

Remarks

The tagSizeInBytes parameter is used to indicate that the tag parameter in Encrypt or Decrypt must be exactly this size. Indicating the required tag size prevents issues where callers of Decrypt may supply a tag as input and that input is truncated to an unexpected size.

Applies to

.NET 10 и друге верзије
Производ Верзије
.NET 8, 9, 10

AesGcm(ReadOnlySpan<Byte>, Int32)

Source:
AesGcm.cs
Source:
AesGcm.cs

Initializes a new instance of the AesGcm class with a provided key and required tag size.

C#
public AesGcm(ReadOnlySpan<byte> key, int tagSizeInBytes);

Parameters

key
ReadOnlySpan<Byte>

The secret key to use for this instance.

tagSizeInBytes
Int32

The size of the tag, in bytes, that encryption and decryption must use.

Exceptions

The key parameter length is other than 16, 24, or 32 bytes (128, 192, or 256 bits).

The tagSizeInBytes parameter is an unsupported tag size indicated by TagByteSizes.

The current platform does not support AES-GCM.

Remarks

The tagSizeInBytes parameter is used to indicate that the tag parameter in Encrypt or Decrypt must be exactly this size. Indicating the required tag size prevents issues where callers of Decrypt may supply a tag as input and that input is truncated to an unexpected size.

Applies to

.NET 10 и друге верзије
Производ Верзије
.NET 8, 9, 10