RSA.TrySignData 方法

定义

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

C#
public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding, out int bytesWritten);

参数

data
ReadOnlySpan<Byte>

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

destination
Span<Byte>

要接收 RSA 签名的缓冲区。

hashAlgorithm
HashAlgorithmName

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

padding
RSASignaturePadding

填充模式。

bytesWritten
Int32

此方法返回时,为写入 destination 的字节总数。 该参数未经初始化即被处理。

返回

如果 destination 的长度不足以接收 RSA 签名,则为 true;否则为 false

例外

paddingnull

hashAlgorithm.NamenullEmpty

此实例仅表示一个公钥。

创建签名时出错。

注解

RSA 签名算法将始终生成等于位所需的 KeySize 字节数的输出。

适用于

产品 版本
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

另请参阅