<PackageReference Include="Microsoft.Bcl.Cryptography" Version="10.0.11" />

System.Security.Cryptography.AesGcm

public sealed class AesGcm : IDisposable
Represents an Advanced Encryption Standard (AES) key to be used with the Galois/Counter Mode (GCM) mode of operation.
public static bool IsSupported { get; }

Gets a value that indicates whether the algorithm is supported on the current platform.

public static KeySizes NonceByteSizes { get; }

Gets the nonce sizes, in bytes, supported by this instance.

public static KeySizes TagByteSizes { get; }

Gets the tag sizes, in bytes, supported by this instance.

public int? TagSizeInBytes { get; }

Gets the size of the tag, in bytes.

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

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

public AesGcm(byte[] key, int tagSizeInBytes)

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

public void Decrypt(byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[] associatedData = null)

Decrypts the ciphertext into the provided destination buffer if the authentication tag can be validated.

public void Decrypt(ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> tag, Span<byte> plaintext, ReadOnlySpan<byte> associatedData = default)

Decrypts the ciphertext into the provided destination buffer if the authentication tag can be validated.

public void Dispose()

Releases the resources used by the current instance of the AesGcm class.

public void Encrypt(byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = null)

Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.

public void Encrypt(ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> plaintext, Span<byte> ciphertext, Span<byte> tag, ReadOnlySpan<byte> associatedData = default)

Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.