Files
modernkeepass/ModernKeePassLib/Cryptography/Hash/DigestManaged.cs

32 lines
743 B
C#
Raw Normal View History

using System;
using Org.BouncyCastle.Crypto;
namespace ModernKeePassLib.Cryptography.Hash
{
public abstract class DigestManaged: IDisposable
{
protected IDigest Hash;
public byte[] ComputeHash(byte[] value)
{
return ComputeHash(value, 0, value.Length);
}
public byte[] ComputeHash(byte[] value, int offset, int length)
{
if (value == null) throw new ArgumentNullException(nameof(value));
2017-10-24 14:53:22 +02:00
byte[] resBuf = new byte[Hash.GetDigestSize()];
Hash.BlockUpdate(value, 0, length);
Hash.DoFinal(resBuf, 0);
return resBuf;
}
public void Dispose()
{
Hash.Reset();
}
}
}