Partager via


RSACryptoServiceProvider.SignData Method (array<Byte[], Int32, Int32, Object)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

Namespace:  System.Security.Cryptography
Assembly:  mscorlib.Extensions (in mscorlib.Extensions.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Function SignData ( _
    buffer As Byte(), _
    offset As Integer, _
    count As Integer, _
    halg As Object _
) As Byte()
[SecuritySafeCriticalAttribute]
public byte[] SignData(
    byte[] buffer,
    int offset,
    int count,
    Object halg
)

Parameters

  • buffer
    Type: array<System.Byte[]
    The input data for which to compute the hash.
  • offset
    Type: System.Int32
    The offset into the array from which to begin using data.
  • count
    Type: System.Int32
    The number of bytes in the array to use as data.
  • halg
    Type: System.Object
    The hash algorithm to use to create the hash value.

Return Value

Type: array<System.Byte[]
The RSA signature for the specified data.

Exceptions

Exception Condition
ArgumentNullException

The halg parameter is nulla null reference (Nothing in Visual Basic).

ArgumentException

The halg parameter is not a valid type.

Remarks

This method creates a digital signature that is verified using the VerifyData method.

The halg parameter can accept a String, a HashAlgorithm, or a Type. The string value can be one of the following:

  • The object identifier (OID) friendly name of the hash algorithm to use, either a name registered in the crypto config file or one in the Crypto API OID table.

  • The OID value. The OID must be one recognized by the Crypto API.

For example, you could use SignData(new byte[5], "1.3.14.3.2.26") or SignData(new byte[5], "sha1"), or SignData(new byte[5], "SHA1").

Version Information

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.