SymmetricKeyAlgorithmProvider SymmetricKeyAlgorithmProvider SymmetricKeyAlgorithmProvider SymmetricKeyAlgorithmProvider Class

Represents a provider of symmetric key algorithms. For more information, see Cryptographic keys.

Syntax

Declaration

public sealed class SymmetricKeyAlgorithmProviderpublic sealed class SymmetricKeyAlgorithmProviderPublic NotInheritable Class SymmetricKeyAlgorithmProviderpublic sealed class SymmetricKeyAlgorithmProvider

Remarks

You create a SymmetricKeyAlgorithmProvider object by calling the static OpenAlgorithm(String) method and specifying one of the following algorithm names.

  • No padding:+ DES_CBC
  • DES_ECB
  • 3DES_CBC
  • 3DES_ECB
  • RC2_CBC
  • RC2_ECB
  • AES_CBC
  • AES_ECB

  • PKCS#7 block padding modes:+ AES_CBC_PKCS7

  • AES_ECB_PKCS7
  • DES_CBC_PKCS7
  • DES_ECB_PKCS7
  • 3DES_CBC_PKCS7
  • 3DES_ECB_PKCS7
  • RC2_CBC_PKCS7
  • RC2_ECB_PKCS7

  • Authenticated modes (see the EncryptedAndAuthenticatedData class):+ AES_GCM

  • AES_CCM

  • Stream Cipher:+ RC4

Examples

[!code-csharpShowSymmKeyAlgProviderClass]

Properties summary

Gets the name of the open symmetric algorithm.

Gets the size, in bytes, of the cipher block for the open algorithm.

Methods summary

Creates a symmetric key.

Creates an instance of the SymmetricKeyAlgorithmProvider class and opens the specified algorithm for use.

Properties

  • AlgorithmName
    AlgorithmName
    AlgorithmName
    AlgorithmName

    Gets the name of the open symmetric algorithm.

    public string AlgorithmName { get; }public string AlgorithmName { get; }Public ReadOnly Property AlgorithmName As stringpublic string AlgorithmName { get; }

    Property Value

    • string
      string
      string
      string

      Algorithm name.

    Remarks

    You must call OpenAlgorithm(String) before calling this property. The following algorithm names are supported for symmetric cryptographic operations.

  • BlockLength
    BlockLength
    BlockLength
    BlockLength

    Gets the size, in bytes, of the cipher block for the open algorithm.

    public uint BlockLength { get; }public uint BlockLength { get; }Public ReadOnly Property BlockLength As uintpublic uint BlockLength { get; }

    Property Value

    • uint
      uint
      uint
      uint

      Block size.

    Remarks

    If you are not using a PKCS#7 block padding algorithm (which automatically pads your content to the correct length), you must ensure that the message to be encrypted is an exact multiple of the length supported by the algorithm. For more information, see the following code example.

Methods

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Security.Cryptography.Core.dll