Skip to content

Instantly share code, notes, and snippets.

@ElectricImpSampleCode
Last active December 11, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElectricImpSampleCode/b0be1a09cceb24336fec17ef390bc185 to your computer and use it in GitHub Desktop.
Save ElectricImpSampleCode/b0be1a09cceb24336fec17ef390bc185 to your computer and use it in GitHub Desktop.
Electric Imp imp API hash.hmacsha512() example code
function blobToHexString(data) {
local s = "0x";
foreach (b in data) s += format("%02X", b);
return s;
}
function testHash() {
local data = "The quick brown fox jumps over the lazy dog";
local key = "key";
local hash = http.hash.hmacsha512(data, key);
server.log("Hex: " + blobToHexString(hash));
server.log("Base64: " + http.base64encode(hash));
}
testHash();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment