RSA.SignHash Method

Definition

Overloads

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

When overridden in a derived class, computes the signature for the specified hash value using the specified padding.

SignHash(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

Computes the signature for the specified hash value using the specified padding.

SignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

Signs the hash with the current key, writing the signature into a provided buffer.

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

Source:
RSA.cs
Source:
RSA.cs
Source:
RSA.cs

When overridden in a derived class, computes the signature for the specified hash value using the specified padding.

C#
public virtual byte[] SignHash (byte[] hash, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);
C#
public abstract byte[] SignHash (byte[] hash, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

Parameters

hash
Byte[]

The hash value of the data to be signed.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash value of the data.

padding
RSASignaturePadding

The padding.

Returns

Byte[]

The RSA signature for the specified hash value.

Exceptions

A derived class must override this method.

data or padding is null.

hashAlgorithm.Name is null or Empty.

padding is unknown, or not supported by this implementation.

-or-

This instance represents only a public key.

-or-

An error occurred creating the signature.

See also

Applies to

.NET 9 en andere versies
Product Versies
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

SignHash(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

Source:
RSA.cs
Source:
RSA.cs
Source:
RSA.cs

Computes the signature for the specified hash value using the specified padding.

C#
public byte[] SignHash (ReadOnlySpan<byte> hash, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

Parameters

hash
ReadOnlySpan<Byte>

The hash value of the data to be signed.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash of hash.

padding
RSASignaturePadding

The padding mode.

Returns

Byte[]

The RSA signature for the specified hash value.

Exceptions

padding or hashAlgorithm's Name is null.

hashAlgorithm's Name is an empty string.

padding is unknown, or not supported by this implementation.

-or-

This instance represents only a public key.

-or-

An error occurred creating the signature.

Applies to

.NET 9 en andere versies
Product Versies
.NET 7, 8, 9

SignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

Source:
RSA.cs
Source:
RSA.cs
Source:
RSA.cs

Signs the hash with the current key, writing the signature into a provided buffer.

C#
public int SignHash (ReadOnlySpan<byte> hash, Span<byte> destination, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

Parameters

hash
ReadOnlySpan<Byte>

The hash value of the data to be signed.

destination
Span<Byte>

The buffer to receive the RSA signature.

hashAlgorithm
HashAlgorithmName

The hash algorithm used to create the hash of hash.

padding
RSASignaturePadding

The padding mode.

Returns

The total number of bytes written to destination.

Exceptions

padding or hashAlgorithm's Name is null.

hashAlgorithm's Name is an empty string.

-or-

The buffer in destination is too small to hold the signature.

padding is unknown, or not supported by this implementation.

-or-

This instance represents only a public key.

-or-

An error occurred creating the signature.

Applies to

.NET 9 en andere versies
Product Versies
.NET 7, 8, 9