在 Lua 中运行 HMAC-SHA1

我已经从 luarocks 安装了 lua-resty-hmac 和 luacrypto ,并想在 Lua 中使用 hmac 和 sha1 进行加密。我阅读了以下线程:在 Lightroom 插件中如何使用 Lua 中的 HMAC。我正在尝试以下内容

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]: ?

请指导我在哪里出错了。

点赞