// dnlib: See LICENSE.txt for more info using System.Threading; namespace dnlib.DotNet { /// /// Represents a public key /// public sealed class PublicKey : PublicKeyBase { const AssemblyHashAlgorithm DEFAULT_ALGORITHM = AssemblyHashAlgorithm.SHA1; PublicKeyToken publicKeyToken; /// /// Gets the /// public override PublicKeyToken Token { get { if (publicKeyToken is null && !IsNullOrEmpty) Interlocked.CompareExchange(ref publicKeyToken, AssemblyHash.CreatePublicKeyToken(data), null); return publicKeyToken; } } /// public override byte[] Data => data; /// /// Constructor /// public PublicKey() : base((byte[])null) { } /// /// Constructor /// /// Public key data public PublicKey(byte[] data) : base(data) { } /// /// Constructor /// /// Public key data as a hex string or the string "null" /// to set public key data to null public PublicKey(string hexString) : base(hexString) { } /// public override bool Equals(object obj) { if ((object)this == obj) return true; var other = obj as PublicKey; if (other is null) return false; return Utils.Equals(Data, other.Data); } /// public override int GetHashCode() => Utils.GetHashCode(Data); } }