mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Blake2b also implemented, but not tested ModernKeePass app better implements focus on database password box (but still not working correctly)
32 lines
738 B
C#
32 lines
738 B
C#
using System;
|
|
using Org.BouncyCastle.Crypto.Macs;
|
|
|
|
namespace ModernKeePassLib.Cryptography.Hash
|
|
{
|
|
public class HMAC : IDisposable
|
|
{
|
|
protected HMac _hmac;
|
|
|
|
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));
|
|
|
|
byte[] resBuf = new byte[_hmac.GetMacSize()];
|
|
_hmac.BlockUpdate(value, 0, length);
|
|
_hmac.DoFinal(resBuf, 0);
|
|
|
|
return resBuf;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_hmac.Reset();
|
|
}
|
|
}
|
|
}
|