Skip to main content

crypto.hmacsha256(dataToHash, key)

Performs an HMAC-SHA-256 hash function

Availability

Device

Parameters

Name Type Description
dataToHash String or blob The data to which the hash function will be applied
key String or blob The hash key

Returns

Blob — the hashed data (32 bytes)

Description

This method brings to the device equivalent functionality to the agent’s http.hash.hmacsha256(). It performs an HMAC-SHA256 hash using the input data and key.

Device Performance Note

The hashing function provided by crypto.hmacsha256() is computationally intensive, and customers should be aware that calling the method may have an impact on application performance on the device.

For example, on an imp004m, using 32-byte messages and keys, crypto.hmacsha256() takes approximately 1000-1100µs. For longer messages, the throughput is approximately 1.2MB/s.

The imp004m is the slowest imp currently available, so this represents the worst performance a customer might see. Other imps will perform these operations more quickly.