在Lua中运行HMAC-SHA1

时间:2016-02-02 09:51:51

标签: lua cryptography hmac hmacsha1

我已经从luarocks安装了lua-resty-hmac和luacrypto,并希望在Lua中使用hmac和sha1执行加密。我已经完成了以下帖子How to use HMAC in Lua - Lightroom plugin。我正在尝试以下

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

但是当我执行此操作时,我收到以下错误 -

lua: /home/agile/Music/works/Lua/lua-resty-hmac-master/lib/resty/hmac.lua:4: module 'crypto' not found:
    no field package.preload['crypto']
    no file './crypto.lua'
    no file '/usr/share/lua/5.1/crypto.lua'
    no file '/usr/share/lua/5.1/crypto/init.lua'
    no file '/usr/lib64/lua/5.1/crypto.lua'
    no file '/usr/lib64/lua/5.1/crypto/init.lua'
    no file '/home/agile/Music/works/Lua/lua-resty-hmac-master/lib/resty/crypto.lua'
    no file './crypto.so'
    no file '/usr/lib64/lua/5.1/crypto.so'
    no file '/usr/lib64/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    /home/agile/Music/works/Lua/lua-resty-hmac-master/lib/resty/hmac.lua:4: in main chunk
    [C]: in function 'require'
    3.lua:2: in main chunk
    [C]: ?

请说明我做错了。

0 个答案:

没有答案