Mac
class in package klyn.cryptography

    public abstract class Mac extends Object:

Object
└ Mac

Abstract base class for keyed message authentication codes.

The primary public HMAC API is exposed through `Hmac`, which binds the MAC to a concrete hash algorithm such as `SHA256()` or `SHA3_512()`.

    import klyn.cryptography

    mac as Mac = Hmac(SHA256())
    mac.init("secret")
    print(mac.doFinal("hello").hex)

Fields

Modifier and Type | Member | Description
--- | --- | ---
public readonly | algorithm `algorithm as String` | Canonical MAC algorithm name.
public readonly | hashAlgorithm `hashAlgorithm as String` | Canonical digest algorithm name used by this MAC.

Properties inherited from Object: type
Methods

Modifier and Type | Member | Description
--- | --- | ---
public | doFinal `doFinal(text as String = null) as Digest throws CryptoException:` | Computes the MAC for the buffered text and an optional final chunk.
public static | getInstance `getInstance(algorithm as String) as Mac throws CryptoException:` | Compatibility factory for dynamic algorithm selection.
public | init `init(key as String, keyEncoding as String = "utf8") as Void:` | Loads the secret key used to compute the MAC.
public | reset `reset() as Void:` | Clears the buffered text accumulated with `update`.
public override | toString `toString() as String:` | No summary.
public | update `update(text as String) as Mac:` | Appends text to the in-memory MAC buffer.
public | verify `verify(text as String, expected as String, expectedEncoding as String = "hex") as Boolean throws CryptoException:` | Verifies a MAC value against the provided message.

Methods inherited from Object: fromJson, toDict, toJson, toString, toXml