From 04fa96b7c0abba4d7cca03ed12ff3b65b3912e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 13 Aug 2022 01:23:32 +0800 Subject: fix #1431 --- meta/3rd/OpenResty/library/resty/aes.lua | 75 ++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 meta/3rd/OpenResty/library/resty/aes.lua (limited to 'meta/3rd/OpenResty/library/resty/aes.lua') diff --git a/meta/3rd/OpenResty/library/resty/aes.lua b/meta/3rd/OpenResty/library/resty/aes.lua new file mode 100644 index 00000000..7e627ef6 --- /dev/null +++ b/meta/3rd/OpenResty/library/resty/aes.lua @@ -0,0 +1,75 @@ +---@meta + +local aes={} + +---@alias resty.aes.cipher.name +---| '"ecb"' +---| '"cbc"' +---| '"cfb1"' +---| '"cfb128"' +---| '"cfb8"' +---| '"ctr" +---| '"gcm"' +---| '"ofb"' + +---@alias resty.aes.cipher.size '128'|'192'|'256' + +---@class resty.aes.cipher : table +---@field size resty.aes.cipher.size +---@field cipher resty.aes.cipher.name +---@field method userdata + +---@param size resty.aes.cipher.size # cipher size (default `128`) +---@param cipher? resty.aes.cipher.name # cipher name (default `"cbc"`) +---@return resty.aes.cipher? +function aes.cipher(size, cipher) end + +---@class resty.aes.hash_table : table +---@field iv string +---@field method? fun(key:string):string + +---@class resty.aes.hash_cdata : userdata + +---@type table +aes.hash = {} +aes.hash.sha1={} +aes.hash.md5={} +aes.hash.sha224={} +aes.hash.sha512={} +aes.hash.sha256={} +aes.hash.sha384={} + +---@alias resty.aes.hash resty.aes.hash_cdata|resty.aes.hash_table + +---@param key string encryption key +---@param salt? string if provided, must be exactly 8 characters in length +---@param cipher? resty.aes.cipher (default is 128 CBC) +---@param hash? resty.aes.hash (default is md5) +---@param hash_rounds? number (default: `1`) +---@param iv_len? number +---@param enable_padding? boolean (default: `true`) +--- +---@return resty.aes? +---@return string? error +function aes:new(key, salt, cipher, hash, hash_rounds, iv_len, enable_padding) end + +---@class resty.aes : table +local aes_ctx = {} + +--- Decrypt a string +--- +---@param s string +---@param tag? string +---@return string? decrypted +---@return string? error +function aes_ctx:decrypt(s, tag) end + + +--- Encrypt a string. +--- +---@param s string +---@return string? encrypted +---@return string? error +function aes_ctx:encrypt(s) end + +return aes \ No newline at end of file -- cgit v1.2.3