How to use HMAC in Lua plugin - Lightroom

First of all, I should mention that I am really very new to Lua and please be patient if you think my question is too stupid

Here is my requirement

  • I need to use HMAC-sha256 to develop Lightroom plugins, as I use this for security.

I tried to use this but no luck https://code.google.com/p/lua-files/wiki/hmac

These are the steps that I followed.

Now in the file I use it as follows

local hmac = require'hmac'
local sha2 = require'sha2'

--somewhere doend the line inside a function
local hashvalue = hmac.sha2('key', 'message')

but unfortunately this does not work, and I'm not sure what I'm doing wrong. Can someone advise me what I'm doing wrong here? Or there is an easier and better way to do this with a good example.

EDIT: I do this to get the result. When I include this code, the plugin stops working. I can not get the output line when I do this

hashvalue = hmac.sha2('key', 'message')

local LrLogger = import 'LrLogger'
myLogger = LrLogger('FlaggedFiles')
myLogger:enable("logfile")
myLogger:trace ("=========================================\n") 
myLogger:trace ('Winter is coming, ' .. hashvalue)
myLogger:trace ("=========================================\n")

and Lightroom refuses to download the plugin, and there is nothing in the magazine.

Many thanks for your help.

+4
source share
3 answers

, Lightroom. , HMAC-, , : "", "" "ffi". bit ffi , , Lightroom ( ). , , LR, , LR.

+2

SHA256, Lightroom

. SDK (Lightroom SDK)

local sha = import 'LrDigest'
d = sha.SHA256.digest ("Hello world")

, , HMAC, md5 , .

0

It took quite some time trying to find a solution: - / LrDigest is not documented, thanks Adobe! Decision:

local LrDigest = import "LrDigest"
LrDigest.HMAC.digest(string, 'SHA256', key)
0
source

Source: https://habr.com/ru/post/1545781/


All Articles