/// <summary> /// File content hash calculation /// </summary> public static QuickIOHashResult CalculateHash( QuickIOPathInfo pathInfo, QuickIOHashImplementationType hashImplementationType ) { Contract.Requires( pathInfo != null ); switch( hashImplementationType ) { case QuickIOHashImplementationType.SHA1: return CalculateSha1Hash( pathInfo ); case QuickIOHashImplementationType.SHA256: return CalculateSha256Hash( pathInfo ); case QuickIOHashImplementationType.SHA384: return CalculateSha384Hash( pathInfo ); case QuickIOHashImplementationType.SHA512: return CalculateSha512Hash( pathInfo ); case QuickIOHashImplementationType.MD5: return CalculateMD5Hash( pathInfo ); default: throw new NotImplementedException( "Type " + hashImplementationType + " not implemented." ); } }
/// <summary> /// File chunk hash calculation /// </summary> public QuickIOHashResult CalculateHash( QuickIOHashImplementationType hashImplementationType ) { switch ( hashImplementationType ) { case QuickIOHashImplementationType.SHA1: return CalculateHash( new SHA1Managed( ) ); case QuickIOHashImplementationType.SHA256: return CalculateHash( new SHA256Managed( ) ); case QuickIOHashImplementationType.SHA384: return CalculateHash( new SHA384Managed( ) ); case QuickIOHashImplementationType.SHA512: return CalculateHash( new SHA512Managed( ) ); case QuickIOHashImplementationType.MD5: return CalculateHash( new MD5CryptoServiceProvider( ) ); default: throw new NotImplementedException( "Type " + hashImplementationType + " not implemented." ); } }
/// <summary> /// File chunk hash calculation /// </summary> public QuickIOHashResult CalculateHash( QuickIOHashImplementationType hashImplementationType ) { Contract.Ensures( Contract.Result<QuickIOHashResult>() != null ); HashAlgorithm hashAlgorithm; switch( hashImplementationType ) { case QuickIOHashImplementationType.SHA1: hashAlgorithm = new SHA1Managed(); break; case QuickIOHashImplementationType.SHA256: hashAlgorithm = new SHA256Managed(); break; case QuickIOHashImplementationType.SHA384: hashAlgorithm = new SHA384Managed(); break; case QuickIOHashImplementationType.SHA512: hashAlgorithm = new SHA512Managed(); break; case QuickIOHashImplementationType.MD5: hashAlgorithm = new MD5CryptoServiceProvider(); break; default: throw new NotImplementedException( "Type " + hashImplementationType + " not implemented." ); } return CalculateHash( hashAlgorithm ); }
/// <summary> /// File content hash calculation /// </summary> public Task<QuickIOHashResult> CalculateHashAsync( QuickIOHashImplementationType hashImplementationType ) { return NETCompatibility.AsyncExtensions.GetAsyncResult( () => CalculateHash( hashImplementationType ) ); }
/// <summary> /// File content hash calculation /// </summary> public QuickIOHashResult CalculateHash( QuickIOHashImplementationType hashImplementationType ) { return QuickIOFile.CalculateHash( PathInfo, hashImplementationType ); }