Parameters
- other
Library/Library.Test/TestHash.cs
C# | Copy Code |
---|---|
Random r = new Random(); byte[] a = new byte[10], b = new byte[10]; r.NextBytes(a); r.NextBytes(b); Hash h1 = Hash.SHA256(a); Hash h2 = Hash.SHA1(b); Hash h3 = h1.Combine(h2); Assert.AreEqual(h3.ToString(), Hash.SHA256( new CombinedStream( new MemoryStream(h1.ToArray()), new MemoryStream(Hash.SHA256(h2.ToArray()).ToArray()) //the dissimilar hash is first made the same length )).ToString()); |
VB.NET | Copy Code |
---|---|
Dim r As New Random() Dim a As Byte() = New Byte(10) {}, b As Byte() = New Byte(10) {} r.NextBytes(a) r.NextBytes(b) Dim h1 As Hash = Hash.SHA256(a) Dim h2 As Hash = Hash.SHA1(b) Dim h3 As Hash = h1.Combine(h2) 'the dissimilar hash is first made the same length Assert.AreEqual(h3.ToString(), Hash.SHA256(New CombinedStream(New MemoryStream(h1.ToArray()), New MemoryStream(Hash.SHA256(h2.ToArray()).ToArray()))).ToString()) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
Hash ClassHash Members
Overload List