KeyedHashAlgorithm.Key 属性

定义

获取或设置用于哈希算法的密钥。Gets or sets the key to use in the hash algorithm.

public:
 virtual property cli::array <System::Byte> ^ Key { cli::array <System::Byte> ^ get(); void set(cli::array <System::Byte> ^ value); };
public virtual byte[] Key { get; set; }
member this.Key : byte[] with get, set
Public Overridable Property Key As Byte()

属性值

Byte[]

用于哈希算法的密钥。The key to use in the hash algorithm.

异常

尝试在哈希计算已开始后更改 Key 属性。An attempt was made to change the Key property after hashing has begun.

示例

下面的代码示例演示如何重写 Key 属性以检索当前 KeyedHashAlgorithm 对象中使用的键。The following code example demonstrates how to override the Key property to retrieve the key used in the current KeyedHashAlgorithm object. 此代码示例是为 KeyedHashAlgorithm 类提供的更大示例的一部分。This code example is part of a larger example provided for the KeyedHashAlgorithm class.

   virtual array<Byte>^ get() override
   {
      return dynamic_cast<array<Byte>^>(keyedCrypto->Key->Clone());
   }

   virtual void set( array<Byte>^value ) override
   {
      keyedCrypto->Key = dynamic_cast<array<Byte>^>(value->Clone());
   }
}
public override byte[] Key
{
    get
    {
        return (byte[]) keyedCrypto.Key.Clone();
    }
    set
    {
        keyedCrypto.Key = (byte[]) value.Clone();
    }
}
Public Overrides Property Key() As Byte()
    Get
        Return CType(keyedCrypto.Key.Clone(), Byte())
    End Get
    Set(ByVal Value As Byte())
        keyedCrypto.Key = CType(Value.Clone(), Byte())
    End Set
End Property

注解

此属性是 KeyValue 字段的公共访问器。This property is the public accessor for the KeyValue field.

适用于

另请参阅