CryptographicOperations.TryHashData 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
尝试计算数据的哈希。
public:
static bool TryHashData(System::Security::Cryptography::HashAlgorithmName hashAlgorithm, ReadOnlySpan<System::Byte> source, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public static bool TryHashData(System.Security.Cryptography.HashAlgorithmName hashAlgorithm, ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);
static member TryHashData : System.Security.Cryptography.HashAlgorithmName * ReadOnlySpan<byte> * Span<byte> * int -> bool
Public Shared Function TryHashData (hashAlgorithm As HashAlgorithmName, source As ReadOnlySpan(Of Byte), destination As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean
参数
- hashAlgorithm
- HashAlgorithmName
用于计算哈希的算法。
- source
- ReadOnlySpan<Byte>
要哈希的数据。
- bytesWritten
- Int32
此方法返回时,写入 destination的字节总数。
返回
如果 destination 太小而无法保存计算哈希,则 false 否则 true。
例外
hashAlgorithm 有一个为空的 Name。
hashAlgorithm 有一个 null的 Name。
hashAlgorithm 指定当前平台不支持的哈希算法。
hashAlgorithm 指定未知哈希算法。