KeyedHashAlgorithm.Key 属性

定义

获取或设置用于哈希算法的密钥。

C#
public virtual byte[] Key { get; set; }

属性值

Byte[]

用于哈希算法的密钥。

例外

尝试在哈希计算已开始后更改 Key 属性。

示例

下面的代码示例演示如何重写 Key 属性以检索当前 KeyedHashAlgorithm 对象中使用的键。 此代码示例是为 KeyedHashAlgorithm 类提供的一个更大示例的一部分。

C#
public override byte[] Key
{
    get
    {
        return (byte[]) keyedCrypto.Key.Clone();
    }
    set
    {
        keyedCrypto.Key = (byte[]) value.Clone();
    }
}

注解

此属性是 字段的公共访问器 KeyValue

适用于

产品 版本
.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 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 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

另请参阅