Example #1
0
        public bool Equals(Sha256Hash other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Sha256HashBuffer.Equal(ref _buffer, ref other._buffer));
        }
Example #2
0
 public static bool Equal(ref Sha256HashBuffer first, ref Sha256HashBuffer second)
 {
     unsafe
     {
         fixed(byte *p1 = first._data, p2 = second._data)
         {
             return(*(ulong *)(p1) == *(ulong *)(p2) &&
                    *(ulong *)(p1 + 8) == *(ulong *)(p2 + 8) &&
                    *(ulong *)(p1 + 16) == *(ulong *)(p2 + 16) &&
                    *(ulong *)(p1 + 24) == *(ulong *)(p2 + 24));
         }
     }
 }
Example #3
0
        public static string ToString(ref Sha256HashBuffer buffer)
        {
            var reverseCopy = new byte[Length];

            unsafe
            {
                fixed(byte *p = buffer._data)
                {
                    for (int i = 0, j = Length - 1; i < Length; ++i, --j)
                    {
                        reverseCopy[i] = p[j];
                    }
                }
            }

            return(Hexadecimal.Encode(reverseCopy));
        }
Example #4
0
 public override string ToString() => Sha256HashBuffer.ToString(ref _buffer);
Example #5
0
 public Sha256Hash(byte[] hash)
 {
     _buffer = Sha256HashBuffer.CopyFrom(hash);
 }