Skip to main content



Device, Agent


The crypto object can be used to perform various cryptography functions in Squirrel. This can be used to ensure data integrity, and is useful in a number of security applications.

It primarily provides key methods that replicate on the device certain security functionality previously provided only by the agent by way of the hash object. It also provides a number of agent-oriented cryptography tools.

Agent Usage Note

While the crypto methods are now supported in agent code, this is only the case with agents paired to development devices. Agents paired with production devices cannot yet make use of these methods.

Device Performance Note

The hashing functions provided by the crypto object are computationally intensive, and customers should be aware that calling the object’s methods may have an impact on application performance on the device.

For example, on an imp004m, using 32-byte messages and keys, crypto.sha256() takes approximately 740-800µs, and 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.

The crypto object has the following member methods: