Exemplo n.º 1
0
        private void CalculateHashes()
        {
            IHash sha = Sha256.CreateSha256Generator();

            foreach (Entry entry in Entries)
            {
                if (entry.HashLength == 0)
                {
                    entry.HashLength = 0x200;
                }

                var data = new byte[entry.HashLength];
                entry.File.Read(out long bytesRead, entry.HashOffset, data);

                if (bytesRead != entry.HashLength)
                {
                    throw new ArgumentOutOfRangeException();
                }

                entry.Hash = new byte[Sha256.DigestSize];

                sha.Initialize();
                sha.Update(data);
                sha.GetHash(entry.Hash);
            }
        }
Exemplo n.º 2
0
 public static void Encrypt()
 {
     foreach (HashTestVector tv in TestVectors)
     {
         Common.HashTestCore(tv.Message.AsSpan(0, tv.LengthBytes), tv.Digest, Sha256.CreateSha256Generator());
     }
 }
Exemplo n.º 3
0
 //[Theory, MemberData(nameof(TestVectors_Individual))]
 public static void Encrypt_Individual(HashTestVector tv)
 {
     Common.HashTestCore(tv.Message.AsSpan(0, tv.LengthBytes), tv.Digest, Sha256.CreateSha256Generator());
 }