https://github.com/wojtekb30/fibaro-lua-hmac_sha256
Pure LUA 5.2 implementation of HMAC_SHA256 algorithm, works in Fibaro Home Center 3.
https://github.com/wojtekb30/fibaro-lua-hmac_sha256
authentication-backend fibaro fibaro-hc3 fibaro-home-center hmac-authentication hmac-sha256 lua
Last synced: about 2 months ago
JSON representation
Pure LUA 5.2 implementation of HMAC_SHA256 algorithm, works in Fibaro Home Center 3.
- Host: GitHub
- URL: https://github.com/wojtekb30/fibaro-lua-hmac_sha256
- Owner: Wojtekb30
- License: mit
- Created: 2024-11-09T20:56:57.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-09T21:09:47.000Z (6 months ago)
- Last Synced: 2025-01-23T13:33:02.718Z (3 months ago)
- Topics: authentication-backend, fibaro, fibaro-hc3, fibaro-home-center, hmac-authentication, hmac-sha256, lua
- Language: Lua
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fibaro-HMAC_SHA256
Pure LUA 5.2 implementation of HMAC_SHA256 algorithm, works in Fibaro Home Center 3. Also contains code for generating SHA256 of a string.Paste the code into your LUA 5.2 script or Fibaro HC3 LUA scene, and then use hmac_sha256() function to have the string encrypted with HMAC_SHA256. Or use sha256() to generate SHA256 of a string.
Useful for making API calls, for example those with Tuya API. HMAC_SHA256 is used in authentication.
Usage example for hmac_256 (assuming the whole function code was copied and pasted into the script):
local client_id = "abc"
local secret = "abcdefgh"
local timestamp = "123" --Current time in miliseconds
local nonce = "456abce" --Random value like Python os.urandom(16) would return
local message = client_id .. timestamp .. nonce
print("Message:", message)
local signature = hmac_sha256(secret, message) --first key, then content, both strings
print("Generated Signature:", signature)