Last active
December 11, 2019 15:26
-
-
Save ElectricImpSampleCode/88b239a705c72a1c0b7dc34e58c1c26f to your computer and use it in GitHub Desktop.
Electric Imp imp API hash.hmacsha256() example code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.hmacsha256(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