private void ReadOctoDeltaHeader() { var version = reader.ReadByte(); if (version != OctoBinaryFormat.Version) { throw new InvalidDataException("The delta file uses a newer file format than this program can handle."); } var hashAlgorithmName = reader.ReadString(); hashAlgorithm = SupportedAlgorithms.Hashing.Create(hashAlgorithmName); var hashLength = reader.ReadInt32(); expectedHash = reader.ReadBytes(hashLength); var endOfMeta = reader.ReadBytes(OctoBinaryFormat.EndOfMetadata.Length); if (!StructuralComparisons.StructuralEqualityComparer.Equals(OctoBinaryFormat.EndOfMetadata, endOfMeta)) { throw new InvalidDataException("The delta file appears to be corrupt."); } _metadata = new DeltaMetadata { HashAlgorithm = hashAlgorithmName, ExpectedFileHashAlgorithm = hashAlgorithmName, ExpectedFileHash = Convert.ToBase64String(expectedHash) }; type = RsyncFormatType.Octodiff; }
public Signature(SignatureMetadata metadata, RsyncFormatType type) { HashAlgorithm = SupportedAlgorithms.Hashing.Create(metadata.ChunkHashAlgorithm); RollingChecksumAlgorithm = SupportedAlgorithms.Checksum.Create(metadata.RollingChecksumAlgorithm); Chunks = new List <ChunkSignature>(); Metadata = metadata; Type = type; }
private void ReadFastRsyncDeltaHeader() { var version = reader.ReadByte(); if (version != FastRsyncBinaryFormat.Version) { throw new InvalidDataException("The delta file uses a newer file format than this program can handle."); } var metadataStr = reader.ReadString(); _metadata = JsonConvert.DeserializeObject <DeltaMetadata>(metadataStr, JsonSerializationSettings.JsonSettings); hashAlgorithm = SupportedAlgorithms.Hashing.Create(_metadata.HashAlgorithm); expectedHash = Convert.FromBase64String(_metadata.ExpectedFileHash); type = RsyncFormatType.FastRsync; }