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); } }
public static void Encrypt() { foreach (HashTestVector tv in TestVectors) { Common.HashTestCore(tv.Message.AsSpan(0, tv.LengthBytes), tv.Digest, Sha256.CreateSha256Generator()); } }
//[Theory, MemberData(nameof(TestVectors_Individual))] public static void Encrypt_Individual(HashTestVector tv) { Common.HashTestCore(tv.Message.AsSpan(0, tv.LengthBytes), tv.Digest, Sha256.CreateSha256Generator()); }