Class HmacSha1
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Mac
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Computes the HMAC-SHA-1 message authentication code.
[Obsolete("HMAC-SHA-1 is provided for legacy compatibility. Prefer HmacSha256 or stronger.")]
public sealed class HmacSha1 : HmacCore, IMac, IDisposable
- Inheritance
-
HmacSha1
- Implements
- Inherited Members
Remarks
This is a fully managed implementation of HMAC-SHA-1 as defined in RFC 2104, using the CryptoHives SHA-1 implementation. It does not rely on OS or hardware cryptographic APIs, ensuring deterministic behavior across all platforms.
HMAC-SHA-1 produces a 160-bit (20-byte) authentication tag.
Security warning: SHA-1 is considered weak for collision resistance. While HMAC-SHA-1 remains secure for authentication, prefer HMAC-SHA-256 or stronger variants for new applications.
Constructors
HmacSha1(byte[])
Initializes a new instance of the HmacSha1 class.
public HmacSha1(byte[] key)
Parameters
keybyte[]The secret key.
Fields
MacSizeBits
The MAC output size in bits.
public const int MacSizeBits = 160
Field Value
MacSizeBytes
The MAC output size in bytes.
public const int MacSizeBytes = 20
Field Value
Methods
Create(byte[])
Creates a new instance of the HmacSha1 class.
public static HmacSha1 Create(byte[] key)
Parameters
keybyte[]The secret key.
Returns
- HmacSha1
A new HMAC-SHA-1 instance.
Hash(byte[], byte[])
Computes the HMAC-SHA-1 tag for the specified key and data in a single operation.
public static byte[] Hash(byte[] key, byte[] data)
Parameters
Returns
- byte[]
The 20-byte MAC tag.