HmacSha256

Provides utilities for generating and verifying HMAC-SHA256 message authentication codes.

HMAC-SHA256 is a keyed-hash message authentication code that uses the SHA-256 hash function. This implementation uses the Bouncy Castle library to compute HMAC-SHA256 tags for input data and verify their integrity. It includes methods for generating keys, computing HMACs, and verifying tags.

The Companion object contains static methods for key generation, HMAC computation, and verification, along with extension functions for convenient use with String and ByteArray. The Result class encapsulates the HMAC tag and the key used for easy handling.

See also

for password hashing utilities

for the random number generator used for key generation

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Result(val tag: ByteArray, val key: ByteArray)

Encapsulates the result of an HMAC-SHA256 operation, containing the tag and the key used.