HashAlgorithm.TryHashFinal(Span<Byte>, Int32) 方法

定义

在哈希算法处理最后一个数据后,尝试结束哈希计算。

C#
protected virtual bool TryHashFinal(Span<byte> destination, out int bytesWritten);

参数

destination
Span<Byte>

要接收哈希值的缓冲区。

bytesWritten
Int32

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

返回

destination 的长度不足以接收哈希值,则为 true;否则为 false

注解

此方法的默认实现是调用 HashFinal() 并将结果复制到 destination

派生类型应重写此方法,以避免创建中间数组。

类对此方法HashAlgorithm的所有调用都已根据 HashSize 属性验证destination是否足够长,因此false返回值是意外的。

适用于

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