Push updated code
This commit is contained in:
parent
d1ce65cce7
commit
62c4eb5850
9 changed files with 549 additions and 2 deletions
38
Integrity/Branch.cs
Normal file
38
Integrity/Branch.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibZNI.Integrity
|
||||
{
|
||||
internal class Branch
|
||||
{
|
||||
private Leaf lA;
|
||||
private Leaf lB;
|
||||
|
||||
public Branch(Leaf a, Leaf b)
|
||||
{
|
||||
lA = a;
|
||||
lB = b;
|
||||
}
|
||||
|
||||
public byte[] GetNodeHash()
|
||||
{
|
||||
byte[] h1 = Tools.SHA256HashBytes(lA.InputBytes);
|
||||
byte[] h2 = Tools.SHA256HashBytes(lB.InputBytes);
|
||||
|
||||
byte[] h3 = new byte[h1.Length + h2.Length];
|
||||
h1.CopyTo(h3, 0);
|
||||
h2.CopyTo(h3, h1.Length);
|
||||
|
||||
byte[] b = Tools.SHA256HashBytes(Tools.SHA256HashBytes(h3));
|
||||
return b;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
byte[] i = GetNodeHash();
|
||||
return Tools.Hash2String(i);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue