예제 #1
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         HashAlgorithm?.Dispose();
     }
 }
예제 #2
0
 public void Dispose()
 {
     _rsa?.Dispose();
     _rsa = null;
     _sha?.Dispose();
     _sha = null;
 }
예제 #3
0
 /// <inheritdoc/>
 public void Dispose()
 {
     lock (stream)
     {
         if (!disposed)
         {
             disposed = true;
             stream?.Dispose();
             hasher?.Dispose();
         }
     }
 }
예제 #4
0
        private bool _disposedValue; // To detect redundant calls

        void Dispose(bool disposing)
        {
            if (_disposedValue)
            {
                return;
            }
            if (disposing)
            {
                _hasher?.Dispose();
            }

            _disposedValue = true;
        }
예제 #5
0
        private bool disposedValue = false;         // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    _hashAlgorithm?.Dispose();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
예제 #6
0
        /// <summary>
        /// Determines if the file given is the same file that the document references. It does the comparison
        /// using the file hash provided in the document against the computed hash of the file on disk.
        /// </summary>
        private bool FileMatchesDocumentReference(Document doc, String file)
        {
            HashAlgorithm hashingAlgorithm = null;
            FileStream    fileStream       = null;

            try
            {
                switch (doc.HashAlgorithm)
                {
                case DocumentHashAlgorithm.MD5:
                    hashingAlgorithm = MD5.Create();
                    break;

                case DocumentHashAlgorithm.SHA1:
                    hashingAlgorithm = SHA1.Create();
                    break;

                case DocumentHashAlgorithm.SHA256:
                    hashingAlgorithm = SHA256.Create();
                    break;

                case DocumentHashAlgorithm.None:
                default:
                    // The file either doesn't have a hash or it's an unknown type of hash. In either case return false for no match.
                    return(false);
                }

                if (!File.Exists(file))
                {
                    // The file doesn't exist, it can't be a match
                    return(false);
                }

                fileStream = File.OpenRead(file);
                byte[] computedHash = hashingAlgorithm.ComputeHash(fileStream);

                return(computedHash.SequenceEqual(doc.Hash));
            }
            finally
            {
                // Cleanup our IDisposable objects
                hashingAlgorithm?.Dispose();
                fileStream?.Dispose();
            }
        }
예제 #7
0
 protected override void DisposeManaged()
 {
     _hasher?.Dispose();
     base.DisposeManaged();
 }
 public void Dispose()
 {
     _rsa?.Dispose();
     _hasher?.Dispose();
 }
 public void Dispose()
 {
     _hashAlgorithm?.Dispose();
     _output?.Dispose();
 }
예제 #10
0
 public void Dispose()
 {
     _Hash?.Dispose();
     _Hash = null;
 }
예제 #11
0
 public void Dispose()
 {
     _symmetricAlgorithm?.Dispose();
     _hashAlgorithm?.Dispose();
 }
예제 #12
0
 public void Dispose()
 {
     checksumStream?.Dispose();
     checksum?.Dispose();
 }
예제 #13
0
 protected virtual void Dispose(bool dispose)
 {
     crypto.Dispose();
     hash.Dispose();
 }
예제 #14
0
 public void Dispose()
 {
     _native.Dispose();
 }