HMAC

public class HMAC : Updatable

Calculates a cryptographic Hash-Based Message Authentication Code (HMAC).

  • Enumerates available algorithms.

    See more

    Declaration

    Swift

    public enum Algorithm
  • Status of the calculation

    Declaration

    Swift

    public internal(set) var status: Status { get }

Lifecycle Methods

  • Creates a new HMAC instance with the specified algorithm and key.

    Declaration

    Swift

    public init(using algorithm: Algorithm, key: Data)

    Parameters

    algorithm

    Selects the algorithm

    key

    Specifies the key as Data

  • Creates a new HMAC instance with the specified algorithm and key.

    Declaration

    Swift

    public init(using algorithm: Algorithm, key: NSData)

    Parameters

    algorithm

    Selects the algorithm

    key

    Specifies the key as NSData

  • Creates a new HMAC instance with the specified algorithm and key.

    Declaration

    Swift

    public init(using algorithm: Algorithm, key: [UInt8])

    Parameters

    algorithm

    Selects the algorithm

    key

    Specifies the key as byte array.

  • Creates a new HMAC instance with the specified algorithm and key string. The key string is converted to bytes using UTF8 encoding.

    Declaration

    Swift

    public init(using algorithm: Algorithm, key: String)

    Parameters

    algorithm

    Selects the algorithm

    key

    Specifies the key as String

Public Methods

  • Updates the calculation of the HMAC with the contents of a buffer.

    Declaration

    Swift

    public func update(from buffer: UnsafeRawPointer, byteCount: size_t) -> `Self`?

    Parameters

    buffer

    Update buffer

    Return Value

    The ‘in-progress’ calculated HMAC

  • Finalizes the HMAC calculation

    Declaration

    Swift

    public func final() -> [UInt8]

    Return Value

    The final calculated HMAC