HmacImportParams
TheHmacImportParams dictionary of theWeb Crypto API represents the object that should be passed when importing, unwrapping, or deriving a key for theHMAC algorithm, as:
- The
algorithmparameter toSubtleCrypto.importKey() - The
unwrappedKeyAlgorithmparameter toSubtleCrypto.unwrapKey() - The
derivedKeyTypeparameter toSubtleCrypto.deriveKey().
In this article
Instance properties
nameA string. This should be set to
HMAC.hashA string or an object containing a single property called
namewith a string value. It is an identifier for thedigest algorithm to use. This should be one of the following:SHA-256: selects theSHA-256 algorithm.SHA-384: selects theSHA-384 algorithm.SHA-512: selects theSHA-512 algorithm.
Warning:
SHA-1is also supported here but theSHA-1 algorithm is considered vulnerable and should no longer be used.lengthOptionalA
Numberrepresenting the length in bits of the key. If this is omitted the length of the key is equal to the length of the digest generated by the digest function you have chosen. Unless you have a good reason to use a different length, omit this property and use the default.
Examples
See the examples forSubtleCrypto.importKey(),SubtleCrypto.unwrapKey(), orSubtleCrypto.deriveKey().
Specifications
| Specification |
|---|
| Web Cryptography Level 2> # dfn-HmacImportParams> |
Browser compatibility
Browsers that support the "HMAC" algorithm for theSubtleCrypto.importKey(),SubtleCrypto.unwrapKey(), orSubtleCrypto.deriveKey() methods will support this type.