Hash 类

定义

提供有关程序集的哈希值的证据。Provides evidence about the hash value for an assembly. 此类不能被继承。This class cannot be inherited.

public ref class Hash sealed : System::Security::Policy::EvidenceBase, System::Runtime::Serialization::ISerializable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class Hash : System.Security.Policy.EvidenceBase, System.Runtime.Serialization.ISerializable
type Hash = class
    inherit EvidenceBase
    interface ISerializable
Public NotInheritable Class Hash
Inherits EvidenceBase
Implements ISerializable
继承
Hash
属性
实现

注解

哈希值表示对应于一组特定字节的唯一值。A hash value represents a unique value that corresponds to a particular set of bytes. 哈希值无歧义地指定程序集, 而不是按名称、版本或其他指定引用程序集。Rather than referring to an assembly by name, version, or other designation, a hash value designates the assembly without ambiguity. 在将同一名称提供给完全不同的代码的罕见情况下, 名称可能会发生冲突。Names are subject to collisions in rare cases where the same name is given to completely different code. 不同版本的代码可能会被意外标记为同一版本。Different variations of code can accidentally be marked with the same version. 但是, 即使更改一个位, 也会导致哈希值非常不同。However, even changing a single bit results in a very different hash value.

哈希值是一种加密安全的方式, 用于在不使用数字签名的情况下引用策略中的特定程序集。Hash values are a cryptographically secure way to refer to specific assemblies in policy without the use of digital signatures. 安全哈希算法旨在使计算无法通过意外或恶意尝试构造具有相同哈希值的不同程序集。A secure hash algorithm is designed so that it is computationally infeasible to construct a different assembly with the identical hash value by either an accidental or malicious attempt. 默认情况下, 会支持SHA1MD5哈希算法中的证据, 尽管任何哈希算法都GenerateHash可以通过使用。By default, evidence from the SHA1 and MD5 hash algorithms is supported, although any hash algorithm can be used through GenerateHash.

由于 MD5 和 SHA1 出现冲突, Microsoft 建议使用基于 SHA256 或更好的安全模型。Due to collision problems with MD5 and SHA1, Microsoft recommends a security model based on SHA256 or better.

构造函数

Hash(Assembly)

初始化 Hash 类的新实例。Initializes a new instance of the Hash class.

属性

MD5

获取程序集的 MD5 哈希值。Gets the MD5 hash value for the assembly.

SHA1

获取程序集的 SHA1 哈希值。Gets the SHA1 hash value for the assembly.

SHA256

获取程序集的 SHA256 哈希值。Gets the SHA256 hash value for the assembly.

方法

Clone()

创建作为当前实例副本的新对象。Creates a new object that is a copy of the current instance.

CreateMD5(Byte[])

创建一个包含 Hash 哈希值的 MD5 对象。Creates a Hash object that contains an MD5 hash value.

CreateSHA1(Byte[])

创建一个包含 Hash 哈希值的 SHA1 对象。Creates a Hash object that contains a SHA1 hash value.

CreateSHA256(Byte[])

创建一个包含 Hash 哈希值的 SHA256 对象。Creates a Hash object that contains a SHA256 hash value.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GenerateHash(HashAlgorithm)

使用指定的哈希算法计算程序集的哈希值。Computes the hash value for the assembly using the specified hash algorithm.

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetObjectData(SerializationInfo, StreamingContext)

获取带有参数名和附加异常信息的 SerializationInfo 对象。Gets the SerializationInfo object with the parameter name and additional exception information.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回当前 Hash 的字符串表示形式。Returns a string representation of the current Hash.

适用于