using System.IO; using SabreTools.IO.Extensions; namespace SabreTools.FileTypes.Aaru { /// /// Checksum entry, followed by checksum data itself /// /// public class ChecksumEntry { /// Checksum algorithm public AaruChecksumAlgorithm type; /// Length in bytes of checksum that follows this structure public uint length; /// Checksum that follows this structure public byte[]? checksum; /// /// Read a stream as an v /// /// ChecksumEntry as a stream /// Populated ChecksumEntry, null on failure public static ChecksumEntry? Deserialize(Stream stream) { var checksumEntry = new ChecksumEntry(); checksumEntry.type = (AaruChecksumAlgorithm)stream.ReadByteValue(); checksumEntry.length = stream.ReadUInt32(); if (checksumEntry.length == 0) return null; checksumEntry.checksum = stream.ReadBytes((int)checksumEntry.length); return checksumEntry; } } }