Mac
classin packageklyn.cryptography
public abstract class Mac extends Object:
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 |
Canonical MAC algorithm name. |
| public readonly |
hashAlgorithm |
Canonical digest algorithm name used by this MAC. |
Methods
| Modifier and Type |
Member |
Description |
| public |
doFinal |
Computes the MAC for the buffered text and an optional final chunk. |
| public static |
getInstance |
Compatibility factory for dynamic algorithm selection. |
| public |
initinit(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 |
No summary. |
| public |
update |
Appends text to the in-memory MAC buffer. |
| public |
verify |
Verifies a MAC value against the provided message. |