MacAlgorithmProvider.AlgorithmName | algorithmName property

Applies to Windows and Windows Phone

Gets the name of the open MAC algorithm.

Syntax


var algorithmName = macAlgorithmProvider.algorithmName;

Property value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

Algorithm name.

Remarks

You must call the OpenAlgorithm method before calling this property. The following algorithm names are supported:

Examples


void CreateHMAC(
    String strMsg,
    String strAlgName,
    out IBuffer buffMsg,
    out CryptographicKey hmacKey,
    out IBuffer buffHMAC)
{
    // Create a MacAlgorithmProvider object for the specified algorithm.
    MacAlgorithmProvider objMacProv = MacAlgorithmProvider.OpenAlgorithm(strAlgName);

    // Demonstrate how to retrieve the name of the algorithm used.
    String strNameUsed = objMacProv.AlgorithmName;

    // Create a buffer that contains the message to be signed.
    BinaryStringEncoding encoding = BinaryStringEncoding.Utf8;
    buffMsg = CryptographicBuffer.ConvertStringToBinary(strMsg, encoding);

    // Create a key to be signed with the message.
    IBuffer buffKeyMaterial = CryptographicBuffer.GenerateRandom(objMacProv.MacLength);
    hmacKey = objMacProv.CreateKey(buffKeyMaterial);

    // Sign the key and message together.
    buffHMAC = CryptographicEngine.Sign(hmacKey, buffMsg);

    // Verify that the HMAC length is correct for the selected algorithm
    if (buffHMAC.Length != objMacProv.MacLength)
    {
        throw new Exception("Error computing digest");
    }
 }


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Security.Cryptography.Core
Windows::Security::Cryptography::Core [C++]

Metadata

Windows.winmd

See also

MacAlgorithmProvider

 

 

Show:
© 2014 Microsoft