예제 #1
0
 public SignatureBuilder(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     ChunkSize      = DefaultChunkSize;
     ProgressReport = null;
 }
예제 #2
0
 public Signature(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm, short chunkSize)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     Chunks    = new List <ChunkSignature>();
     ChunkSize = chunkSize;
 }
예제 #3
0
 public DeltaGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider)
 {
     if (checksumProvider == null) throw new ArgumentNullException("checksumProvider");
     if (hashProvider == null) throw new ArgumentNullException("hashProvider");
     _initialized = false;
     ChecksumProvider = checksumProvider;
     HashProvider = hashProvider;
 }
예제 #4
0
 public void WriteMetadata(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     signatureStream.Write(BinaryFormat.SignatureHeader);
     signatureStream.Write(BinaryFormat.Version);
     signatureStream.Write(hashAlgorithm.Name);
     signatureStream.Write(rollingChecksumAlgorithm.Name);
     signatureStream.Write(BinaryFormat.EndOfMetadata);
 }
예제 #5
0
 public void WriteMetadata(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm, byte[] hash)
 {
     signatureStream.Write(BinaryFormat.SignatureHeader);
     signatureStream.Write(BinaryFormat.Version);
     signatureStream.Write(hashAlgorithm.Name);
     signatureStream.Write(rollingChecksumAlgorithm.Name);
     signatureStream.Write(BinaryFormat.EndOfMetadata);
 }
예제 #6
0
 public HashBlockGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider, int blockSize)
 {
     if (checksumProvider == null) throw new ArgumentNullException("checksumProvider");
     if (hashProvider == null) throw new ArgumentNullException("hashProvider");
     if (blockSize <= 0) throw new ArgumentException("blockSize must be greater than zero");
     ChecksumProvider = checksumProvider;
     HashAlgorithm = hashProvider;
     _blockSize = blockSize;
 }
예제 #7
0
 public DeltaGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider)
 {
     if (checksumProvider == null)
     {
         throw new ArgumentNullException("checksumProvider");
     }
     if (hashProvider == null)
     {
         throw new ArgumentNullException("hashProvider");
     }
     _initialized     = false;
     ChecksumProvider = checksumProvider;
     HashProvider     = hashProvider;
 }
예제 #8
0
 public HashBlockGenerator(IRollingChecksum checksumProvider, IHashAlgorithm hashProvider, int blockSize)
 {
     if (checksumProvider == null)
     {
         throw new ArgumentNullException("checksumProvider");
     }
     if (hashProvider == null)
     {
         throw new ArgumentNullException("hashProvider");
     }
     if (blockSize <= 0)
     {
         throw new ArgumentException("blockSize must be greater than zero");
     }
     ChecksumProvider = checksumProvider;
     HashAlgorithm    = hashProvider;
     _blockSize       = blockSize;
 }
 public OctodiffSignatureBuilder(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     ChunkSize = DefaultChunkSize;
 }
예제 #10
0
 public Signature(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     Chunks = new List<ChunkSignature>();
 }
예제 #11
0
 public OctodiffSignature(IHashAlgorithm hashAlgorithm, IRollingChecksum rollingChecksumAlgorithm)
 {
     HashAlgorithm            = hashAlgorithm;
     RollingChecksumAlgorithm = rollingChecksumAlgorithm;
     Chunks = new List <ChunkSignature>();
 }
예제 #12
0
        public static void ValidateSignature(Stream signatureStream, IHashAlgorithm hashAlgorithm, string baseFileHash, IRollingChecksum rollingAlgorithm)
        {
            signatureStream.Seek(0, SeekOrigin.Begin);
            var sig = new SignatureReader(signatureStream, null).ReadSignature();

            Assert.AreEqual(RsyncFormatType.FastRsync, sig.Type);
            Assert.AreEqual(hashAlgorithm.Name, sig.HashAlgorithm.Name);
            Assert.AreEqual(hashAlgorithm.Name, sig.Metadata.ChunkHashAlgorithm);
            Assert.AreEqual(hashAlgorithm.HashLength, sig.HashAlgorithm.HashLength);
            Assert.AreEqual(rollingAlgorithm.Name, sig.RollingChecksumAlgorithm.Name);
            Assert.AreEqual(rollingAlgorithm.Name, sig.Metadata.RollingChecksumAlgorithm);
            Assert.AreEqual("MD5", sig.Metadata.BaseFileHashAlgorithm);
            Assert.AreEqual(baseFileHash, sig.Metadata.BaseFileHash);
        }