void WriteChunkSignatures(Stream stream, ISignatureWriter signatureWriter) { var checksumAlgorithm = RollingChecksumAlgorithm; var hashAlgorithm = HashAlgorithm; ProgressReporter.ReportProgress("Building signatures", 0, stream.Length); stream.Seek(0, SeekOrigin.Begin); long start = 0; int read; var block = new byte[ChunkSize]; while ((read = stream.Read(block, 0, block.Length)) > 0) { signatureWriter.WriteChunk(new ChunkSignature { StartOffset = start, Length = (short)read, Hash = hashAlgorithm.ComputeHash(block, 0, read), RollingChecksum = checksumAlgorithm.Calculate(block, 0, read) }); start += read; ProgressReporter.ReportProgress("Building signatures", start, stream.Length); } }
void WriteChunkSignatures(Stream stream, ISignatureWriter signatureWriter) { var checksumAlgorithm = RollingChecksumAlgorithm; var hashAlgorithm = HashAlgorithm; //ProgressReporter.ReportProgress("Building signatures", 0, stream.Length); stream.Seek(0, SeekOrigin.Begin); long start = 0; int read; var block = new byte[ChunkSize]; while ((read = stream.Read(block, 0, block.Length)) > 0) { signatureWriter.WriteChunk(new ChunkSignature { StartOffset = start, Length = (short)read, Hash = hashAlgorithm.ComputeHash(block, 0, read), RollingChecksum = checksumAlgorithm.Calculate(block, 0, read) }); start += read; ProgressReporter.ReportProgress("Building signatures", start, stream.Length); } }
void WriteMetadata(Stream stream, ISignatureWriter signatureWriter) { ProgressReporter.ReportProgress("Hashing file", 0, stream.Length); stream.Seek(0, SeekOrigin.Begin); signatureWriter.WriteMetadata(HashAlgorithm, RollingChecksumAlgorithm); ProgressReporter.ReportProgress("Hashing file", stream.Length, stream.Length); }
void WriteMetadata(Stream stream, ISignatureWriter signatureWriter) { ProgressReporter.ReportProgress("Hashing file", 0, stream.Length); stream.Seek(0, SeekOrigin.Begin); var hash = HashAlgorithm.ComputeHash(stream); signatureWriter.WriteMetadata(HashAlgorithm, RollingChecksumAlgorithm, hash); ProgressReporter.ReportProgress("Hashing file", stream.Length, stream.Length); }
public void Build(Stream stream, ISignatureWriter signatureWriter) { WriteMetadata(stream, signatureWriter); WriteChunkSignatures(stream, signatureWriter); }
public void Build(Stream stream, ISignatureWriter signatureWriter) { WriteMetadata(stream, signatureWriter); WriteChunkSignatures(stream, signatureWriter); }
void WriteMetadata(Stream stream, ISignatureWriter signatureWriter) { stream.Seek(0, SeekOrigin.Begin); signatureWriter.WriteMetadata(ChunkSize, HashAlgorithm, RollingChecksumAlgorithm); }