RSA.TrySignData 方法

定义

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

public:
 virtual bool TrySignData(ReadOnlySpan<System::Byte> data, Span<System::Byte> destination, System::Security::Cryptography::HashAlgorithmName hashAlgorithm, System::Security::Cryptography::RSASignaturePadding ^ padding, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding, out int bytesWritten);
abstract member TrySignData : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.HashAlgorithmName * System.Security.Cryptography.RSASignaturePadding * int -> bool
override this.TrySignData : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.HashAlgorithmName * System.Security.Cryptography.RSASignaturePadding * int -> bool
Public Overridable Function TrySignData (data As ReadOnlySpan(Of Byte), destination As Span(Of Byte), hashAlgorithm As HashAlgorithmName, padding As RSASignaturePadding, ByRef bytesWritten As Integer) As Boolean

参数

data
ReadOnlySpan<Byte>

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

destination
Span<Byte>

要接收 RSA 签名的缓冲区。

hashAlgorithm
HashAlgorithmName

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

padding
RSASignaturePadding

填充模式。

bytesWritten
Int32

此方法返回时,包含写入 destination到的字节总数。 此参数被视为未初始化。

返回

true 如果 destination 足够长,无法接收 RSA 签名,则为 ;否则为 false

例外

paddingnull

hashAlgorithmNamenullEmpty

此实例仅表示公钥。

-或-

创建签名时出错。

注解

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

适用于

另请参阅