Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.appveyor.yml
.travis.yml hash based macin Jun 7, 2019
LICENSE docd up Jun 11, 2019
README.md update readme and test imports Jun 22, 2019
mod.ts
test.ts
test_vectors.json
usage.ts

README.md

hmac

Travis AppVeyor

Usage

import { hmac } from "https://denopkg.com/chiefbiiko/hmac/mod.ts";

console.log("HMAC-SHA256 example", hmac("sha256", "key", "msg", "utf8", "hex"));

API

hmac(hash: string, key: string | Uint8Array, msg: string | Uint8Array, inputEncoding?: string, outputEncoding?: string): string | Uint8Array

Convenience function for macing singular data. hash should be one of "sha1", "sha256", or "sha512", with the last two representing the respective SHA2 variants. If key or msg is a string, inputEncoding can be one of "utf8" (fallback), "hex", or "base64". key and msg must have the same encoding if they are both strings.

new HMAC(hasher: Hash, key?: string | Uint8Array)

Creates a HMAC instance. If you pass a key the instance gets initialized. See below for a definition of the Hash interface.

HMAC#init(key: string | Uint8Array, inputEncoding?: string): HMAC

Initializes a HMAC instance. If key is a string, inputEncoding can be one of "utf8" (fallback), "hex", or "base64".

HMAC#update(msg: string | Uint8Array, inputEncoding?: string): HMAC

Updates the instance with a message block. If msg is a string, inputEncoding can be one of "utf8" (fallback), "hex", or "base64".

HMAC#digest(outputEncoding?: string): string | Uint8Array

Obtain a hash based message authentication tag.

interface Hash

A generic representation of a hash algorithm implementation.

export interface Hash {
  hashSize: number;
  init(): Hash;
  update(msg: string | Uint8Array, inputEncoding?: string): Hash;
  digest(outputEncoding?: string): string | Uint8Array;
}

License

MIT

You can’t perform that action at this time.