RSA.SignData 方法

定义

计算指定数据的哈希值,并对其进行签名。

重载

SignData(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定字节的哈希值,并对生产的哈希值进行签名。

SignData(Stream, HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定流的哈希值并签名生成的哈希值。

SignData(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

计算指定数据的哈希值,并对其进行签名。

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

使用指定的算法计算所提供数据的哈希,并使用当前密钥对哈希进行签名,并将签名写入提供的缓冲区。

SignData(Byte[], Int32, Int32, HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定字节数组部分的哈希值并签名生成的哈希值。

SignData(Byte[], HashAlgorithmName, RSASignaturePadding)

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

使用指定的哈希算法和填充模式计算指定字节的哈希值,并对生产的哈希值进行签名。

C#
public byte[] SignData(byte[] data, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

参数

data
Byte[]

要进行哈希处理和签名的输入数据。

hashAlgorithm
HashAlgorithmName

要用于创建哈希值的哈希算法。

padding
RSASignaturePadding

填充模式。

返回

Byte[]

指定的数据的 RSA 签名。

例外

datanull

paddingnull

hashAlgorithm.NamenullEmpty

padding 未知或不受此实现支持。

此实例仅表示一个公钥。

创建签名时出错。

另请参阅

适用于

.NET 10 和其他版本
产品 版本
.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, 10
.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

SignData(Stream, HashAlgorithmName, RSASignaturePadding)

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

使用指定的哈希算法和填充模式计算指定流的哈希值并签名生成的哈希值。

C#
public virtual byte[] SignData(System.IO.Stream data, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

参数

data
Stream

要进行哈希处理和签名的输入流。

hashAlgorithm
HashAlgorithmName

要用于创建哈希值的哈希算法。

padding
RSASignaturePadding

填充模式。

返回

Byte[]

指定的数据的 RSA 签名。

例外

datanull

paddingnull

hashAlgorithm.NamenullEmpty

padding 未知或不受此实现支持。

此实例仅表示一个公钥。

创建签名时出错。

另请参阅

适用于

.NET 10 和其他版本
产品 版本
.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, 10
.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

SignData(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

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

计算指定数据的哈希值,并对其进行签名。

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

参数

data
ReadOnlySpan<Byte>

要进行哈希处理和签名的输入数据。

hashAlgorithm
HashAlgorithmName

要用于创建哈希值的哈希算法。

padding
RSASignaturePadding

填充模式。

返回

Byte[]

指定的数据的 RSA 签名。

例外

paddinghashAlgorithmNamenull

hashAlgorithm Name的 是一个空字符串。

padding 未知或不受此实现支持。

此实例仅表示一个公钥。

创建签名时出错。

适用于

.NET 10 和其他版本
产品 版本
.NET 7, 8, 9, 10

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

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

使用指定的算法计算所提供数据的哈希,并使用当前密钥对哈希进行签名,并将签名写入提供的缓冲区。

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

参数

data
ReadOnlySpan<Byte>

要进行哈希处理和签名的输入数据。

destination
Span<Byte>

要接收 RSA 签名的缓冲区。

hashAlgorithm
HashAlgorithmName

要用于创建哈希值的哈希算法。

padding
RSASignaturePadding

填充模式。

返回

写入 destination 的总字节数。

例外

paddinghashAlgorithmNamenull

hashAlgorithm Name的 是一个空字符串。

-或-

中的 destination 缓冲区太小,无法保存签名。

padding 未知或不受此实现支持。

此实例仅表示一个公钥。

创建签名时出错。

适用于

.NET 10 和其他版本
产品 版本
.NET 7, 8, 9, 10

SignData(Byte[], Int32, Int32, HashAlgorithmName, RSASignaturePadding)

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

使用指定的哈希算法和填充模式计算指定字节数组部分的哈希值并签名生成的哈希值。

C#
public virtual byte[] SignData(byte[] data, int offset, int count, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding);

参数

data
Byte[]

要进行哈希处理和签名的输入数据。

offset
Int32

数组中自其开始使用数据的偏移量。

count
Int32

数组中用作数据的字节数。

hashAlgorithm
HashAlgorithmName

要用于创建哈希值的哈希算法。

padding
RSASignaturePadding

填充模式。

返回

Byte[]

指定的数据的 RSA 签名。

例外

datanull

paddingnull

hashAlgorithm.NamenullEmpty

offset 小于零。

count 小于零。

offset + count - 1 会导致超出 data 上限的索引。

padding 未知或不受此实现支持。

此实例仅表示一个公钥。

创建签名时出错。

另请参阅

适用于

.NET 10 和其他版本
产品 版本
.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, 10
.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