mscorlib(4.0.0.0) API with additions
StrongNamePublicKeyBlob.cs
2 using System.Security.Util;
3 
5 {
8  [ComVisible(true)]
9  public sealed class StrongNamePublicKeyBlob
10  {
11  internal byte[] PublicKey;
12 
13  internal StrongNamePublicKeyBlob()
14  {
15  }
16 
20  public StrongNamePublicKeyBlob(byte[] publicKey)
21  {
22  if (publicKey == null)
23  {
24  throw new ArgumentNullException("PublicKey");
25  }
26  PublicKey = new byte[publicKey.Length];
27  Array.Copy(publicKey, 0, PublicKey, 0, publicKey.Length);
28  }
29 
30  internal StrongNamePublicKeyBlob(string publicKey)
31  {
32  PublicKey = Hex.DecodeHexString(publicKey);
33  }
34 
35  private static bool CompareArrays(byte[] first, byte[] second)
36  {
37  if (first.Length != second.Length)
38  {
39  return false;
40  }
41  int num = first.Length;
42  for (int i = 0; i < num; i++)
43  {
44  if (first[i] != second[i])
45  {
46  return false;
47  }
48  }
49  return true;
50  }
51 
52  internal bool Equals(StrongNamePublicKeyBlob blob)
53  {
54  if (blob == null)
55  {
56  return false;
57  }
58  return CompareArrays(PublicKey, blob.PublicKey);
59  }
60 
65  public override bool Equals(object obj)
66  {
67  if (obj == null || !(obj is StrongNamePublicKeyBlob))
68  {
69  return false;
70  }
71  return Equals((StrongNamePublicKeyBlob)obj);
72  }
73 
74  private static int GetByteArrayHashCode(byte[] baData)
75  {
76  if (baData == null)
77  {
78  return 0;
79  }
80  int num = 0;
81  for (int i = 0; i < baData.Length; i++)
82  {
83  num = ((num << 8) ^ baData[i] ^ (num >> 24));
84  }
85  return num;
86  }
87 
90  public override int GetHashCode()
91  {
92  return GetByteArrayHashCode(PublicKey);
93  }
94 
97  public override string ToString()
98  {
99  return Hex.EncodeHexString(PublicKey);
100  }
101  }
102 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
override int GetHashCode()
Returns a hash code based on the public key.
override string ToString()
Creates and returns a string representation of the public key blob.
Definition: __Canon.cs:3
StrongNamePublicKeyBlob(byte[] publicKey)
Initializes a new instance of the T:System.Security.Permissions.StrongNamePublicKeyBlob class with ra...
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275
Specifies that the class can be serialized.
override bool Equals(object obj)
Gets or sets a value indicating whether the current public key blob is equal to the specified public ...
Represents the public key information (called a blob) for a strong name. This class cannot be inherit...