Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/HashLib4CSharp/HashLib4CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Hydrogen\Hydrogen.csproj" />
</ItemGroup>

</Project>
7 changes: 5 additions & 2 deletions src/HashLib4CSharp/src/Base/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ This library was sponsored by Sphere 10 Software (https://www.sphere10.com)
using System;
using System.Diagnostics;
using HashLib4CSharp.Interfaces;
using Hydrogen;

namespace HashLib4CSharp.Base
{
internal abstract class Hash : IHash
internal abstract class Hash : SyncDisposable, IHash
{
private const string CloneNotYetImplemented = "Clone not yet implemented for '{0}'";
private const string InvalidBufferSize = "'BufferSize' must be greater than zero";
Expand Down Expand Up @@ -55,5 +56,7 @@ public virtual IHash Clone() =>

public abstract void Initialize();
public abstract IHashResult TransformFinal();
}

protected override void FreeManagedResources() {}
}
}
14 changes: 7 additions & 7 deletions src/HashLib4CSharp/src/Base/MultipleTransformNonBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ protected MultipleTransformNonBlock(int hashSize, int blockSize) : base(hashSize

private MemoryStream Buffer { get; }

~MultipleTransformNonBlock()
{
Buffer?.Flush();
Buffer?.Close();
}

private byte[] Aggregate()
{
var aggregate = new byte[0];
Expand Down Expand Up @@ -97,5 +91,11 @@ public override IHashResult TransformFinal()
return result;
}
protected abstract IHashResult ComputeAggregatedBytes(byte[] data);
}

protected override void FreeManagedResources()
{
Buffer?.Flush();
Buffer?.Close();
}
}
}
2 changes: 1 addition & 1 deletion src/HashLib4CSharp/src/Interfaces/IHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This library was sponsored by Sphere 10 Software (https://www.sphere10.com)

namespace HashLib4CSharp.Interfaces
{
public interface IHash
public interface IHash : IDisposable
{
string Name { get; }
int BlockSize { get; }
Expand Down