/*
* Copyright (C) 2006-2007 Eskil Bylund
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
using System.IO;
using System.Threading;
using System.Security.Cryptography;
namespace DCSharp.Hashing{
/// <summary>
/// A class that creates a HashTree from a file.
/// </summary>
public abstract class Hasher
{
#region Properties
/// <summary>
/// Gets the number of bytes that remains to be hashed.
/// </summary>
/// <value>The number of bytes that remains to be hashed.</value>
public abstract long BytesRemaining
{
get;
}
#endregion
#region Methods
/// <summary>
/// Creates a HashTree from a file.
/// </summary>
/// <param name="fileInfo">The file to create the HashTree from.</param>
/// <param name="abortHashingEvent"></param>
/// <returns>The HashTree from the file.</returns>
public abstract HashTree Hash(FileInfo fileInfo,
ManualResetEvent abortHashingEvent);
/// <summary>
/// Creates a Hasher instance.
/// </summary>
/// <param name="algorithm">The hash algorithm to use.</param>
/// <returns>A new Hasher instance.</returns>
public static Hasher Create(HashAlgorithm algorithm)
{
return new HasherManaged(algorithm);
}
#endregion
}
}
|