new HMAC(data)
Creates a new HMAC instance
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Initialization options for the class, passed automatically into HMAC#initialize |
- Copyright:
- Copyright (c) 2013, Jeff Lyon.
- License:
- Source:
Requires
- module:convert
Methods
-
finalize(options) → {string}
-
Finalizes the data hashing, computes and returns the final HMAC hash. This is called internally by hash() when progressive mode is turned off. Otherwise, you call it explicitly when you're done hashing data in progressive mode.
Parameters:
Name Type Argument Default Description options
Object <optional>
{} Options object. (Parameter descriptions below) Properties
Name Type Argument Default Description return_format
string <optional>
'hex' (binary|hex|words) The return format. Default: hex Returns:
- Type
- string
-
hash(data, options) → {mixed}
-
Performs HMAC hashing on message data. This optionally supports streaming mode (or "progressive hashing"), which allows you to hash data in chunks over multiple calls, using the same hasher instance. Progressive hashing should improve memory usage for large datasets, since we don't necessarily need to keep all of it in memory at once. Once you are finished hashing data in progressive mode, call finalize() to return the hash.
Parameters:
Name Type Description data
string | Array Either a string, or array of 8-bit numeric bytes to hash options
Object Options object. (Parameter descriptions below) Properties
Name Type Argument Default Description stream
boolean <optional>
false Uses progressive hashing. Default: false return_format
string <optional>
'hex' (binary|hex|words) The return format. Default: hex Returns:
Returns desired output format if options.stream is false, else this.- Type
- mixed
-
initialize(options) → {HMAC}
-
Initializes the HMAC instance
Parameters:
Name Type Description options
Object Options object. (Parameter descriptions below) Properties
Name Type Argument Default Description passphrase
string Required passphrase hasher
BlockCipher <optional>
SHA1 A Hasher subclass Returns:
This initialized instance- Type
- HMAC
-
reset()
-
Resets the hasher instance used for the HMAC hashing, but maintains key information derived from the passphrase. This effectively allows you to re-use the class without reinitializing / re-specifying the passphrase.