summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/3rd/OpenResty/library/resty.aes.lua88
-rw-r--r--meta/3rd/OpenResty/library/resty.md5.lua22
-rw-r--r--meta/3rd/OpenResty/library/resty.random.lua13
-rw-r--r--meta/3rd/OpenResty/library/resty.sha.lua4
-rw-r--r--meta/3rd/OpenResty/library/resty.sha1.lua16
-rw-r--r--meta/3rd/OpenResty/library/resty.sha224.lua16
-rw-r--r--meta/3rd/OpenResty/library/resty.sha256.lua16
-rw-r--r--meta/3rd/OpenResty/library/resty.sha384.lua16
-rw-r--r--meta/3rd/OpenResty/library/resty.sha512.lua16
-rw-r--r--meta/3rd/OpenResty/library/resty.string.lua79
10 files changed, 219 insertions, 67 deletions
diff --git a/meta/3rd/OpenResty/library/resty.aes.lua b/meta/3rd/OpenResty/library/resty.aes.lua
index 5a8b51cb..7e627ef6 100644
--- a/meta/3rd/OpenResty/library/resty.aes.lua
+++ b/meta/3rd/OpenResty/library/resty.aes.lua
@@ -1,15 +1,75 @@
---@meta
-resty_aes={}
-function resty_aes.cipher() end
-resty_aes.hash={}
-resty_aes.hash.sha1={}
-resty_aes.hash.md5={}
-resty_aes.hash.sha224={}
-resty_aes.hash.sha512={}
-resty_aes.hash.sha256={}
-resty_aes.hash.sha384={}
-function resty_aes.new(self, key, salt, _cipher, _hash, hash_rounds) end
-function resty_aes.decrypt(self, s) end
-resty_aes._VERSION="0.11"
-function resty_aes.encrypt(self, s) end
-return resty_aes \ No newline at end of file
+
+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<string, resty.aes.hash_cdata>
+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
diff --git a/meta/3rd/OpenResty/library/resty.md5.lua b/meta/3rd/OpenResty/library/resty.md5.lua
index bb8204c1..de82b49e 100644
--- a/meta/3rd/OpenResty/library/resty.md5.lua
+++ b/meta/3rd/OpenResty/library/resty.md5.lua
@@ -1,8 +1,16 @@
---@meta
-resty_md5={}
-function resty_md5.final(self) end
-function resty_md5.new(self) end
-function resty_md5.reset(self) end
-resty_md5._VERSION="0.11"
-function resty_md5.update(self, s) end
-return resty_md5 \ No newline at end of file
+
+---@class resty.md5 : resty.string.checksum
+local md5={}
+
+--- Create a new md5 checksum object.
+---@return resty.md5
+function md5:new() end
+
+--- Add a string to the md5 checksum data
+---@param s string
+---@param len? number Optional length (defaults to the length of `s`)
+---@return boolean ok
+function md5:update(s, len) end
+
+return md5 \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.random.lua b/meta/3rd/OpenResty/library/resty.random.lua
index cecba485..c71dae05 100644
--- a/meta/3rd/OpenResty/library/resty.random.lua
+++ b/meta/3rd/OpenResty/library/resty.random.lua
@@ -1,5 +1,10 @@
---@meta
-resty_random={}
-resty_random._VERSION="0.11"
-function resty_random.bytes(len, strong) end
-return resty_random \ No newline at end of file
+local random={}
+
+--- Generate random bytes.
+---@param len integer
+---@param strong boolean
+---@return string
+function random.bytes(len, strong) end
+
+return random \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.sha.lua b/meta/3rd/OpenResty/library/resty.sha.lua
index 0d5ea45b..716d0bd1 100644
--- a/meta/3rd/OpenResty/library/resty.sha.lua
+++ b/meta/3rd/OpenResty/library/resty.sha.lua
@@ -1,4 +1,4 @@
---@meta
-resty_sha={}
-resty_sha._VERSION="0.11"
+local resty_sha={}
+resty_sha._VERSION = require("resty.string")._VERSION
return resty_sha \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.sha1.lua b/meta/3rd/OpenResty/library/resty.sha1.lua
index 32440187..85d5ace1 100644
--- a/meta/3rd/OpenResty/library/resty.sha1.lua
+++ b/meta/3rd/OpenResty/library/resty.sha1.lua
@@ -1,8 +1,10 @@
---@meta
-resty_sha1={}
-function resty_sha1.final(self) end
-function resty_sha1.new(self) end
-function resty_sha1.reset(self) end
-resty_sha1._VERSION="0.11"
-function resty_sha1.update(self, s) end
-return resty_sha1 \ No newline at end of file
+
+---@class resty.sha1 : resty.string.checksum
+local sha1={}
+
+--- Create a new sha1 checksum object.
+---@return resty.sha1
+function sha1:new() end
+
+return sha1 \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.sha224.lua b/meta/3rd/OpenResty/library/resty.sha224.lua
index 4f2e0e52..b45f55cb 100644
--- a/meta/3rd/OpenResty/library/resty.sha224.lua
+++ b/meta/3rd/OpenResty/library/resty.sha224.lua
@@ -1,8 +1,10 @@
---@meta
-resty_sha224={}
-function resty_sha224.final(self) end
-function resty_sha224.new(self) end
-function resty_sha224.reset(self) end
-resty_sha224._VERSION="0.11"
-function resty_sha224.update(self, s) end
-return resty_sha224 \ No newline at end of file
+
+---@class resty.sha244 : resty.string.checksum
+local sha224={}
+
+--- Create a new sha244 checksum object.
+---@return resty.sha244
+function sha224:new() end
+
+return sha224 \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.sha256.lua b/meta/3rd/OpenResty/library/resty.sha256.lua
index 4cf8441a..29e00eeb 100644
--- a/meta/3rd/OpenResty/library/resty.sha256.lua
+++ b/meta/3rd/OpenResty/library/resty.sha256.lua
@@ -1,8 +1,10 @@
---@meta
-resty_sha256={}
-function resty_sha256.final(self) end
-function resty_sha256.new(self) end
-function resty_sha256.reset(self) end
-resty_sha256._VERSION="0.11"
-function resty_sha256.update(self, s) end
-return resty_sha256 \ No newline at end of file
+
+---@class resty.sha256 : resty.string.checksum
+local sha256={}
+
+--- Create a new sha256 checksum object.
+---@return resty.sha256
+function sha256:new() end
+
+return sha256 \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.sha384.lua b/meta/3rd/OpenResty/library/resty.sha384.lua
index 71aac34a..f0e6e7b3 100644
--- a/meta/3rd/OpenResty/library/resty.sha384.lua
+++ b/meta/3rd/OpenResty/library/resty.sha384.lua
@@ -1,8 +1,10 @@
---@meta
-resty_sha384={}
-function resty_sha384.final(self) end
-function resty_sha384.new(self) end
-function resty_sha384.reset(self) end
-resty_sha384._VERSION="0.11"
-function resty_sha384.update(self, s) end
-return resty_sha384 \ No newline at end of file
+
+---@class resty.sha384 : resty.string.checksum
+local sha384={}
+
+--- Create a new sha384 checksum object.
+---@return resty.sha384
+function sha384:new() end
+
+return sha384 \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.sha512.lua b/meta/3rd/OpenResty/library/resty.sha512.lua
index 06ac143a..afa1e946 100644
--- a/meta/3rd/OpenResty/library/resty.sha512.lua
+++ b/meta/3rd/OpenResty/library/resty.sha512.lua
@@ -1,8 +1,10 @@
---@meta
-resty_sha512={}
-function resty_sha512.final(self) end
-function resty_sha512.new(self) end
-function resty_sha512.reset(self) end
-resty_sha512._VERSION="0.11"
-function resty_sha512.update(self, s) end
-return resty_sha512 \ No newline at end of file
+
+---@class resty.sha512 : resty.string.checksum
+local sha512={}
+
+--- Create a new sha512 checksum object.
+---@return resty.sha512
+function sha512:new() end
+
+return sha512 \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.string.lua b/meta/3rd/OpenResty/library/resty.string.lua
index 9931b0ec..e9852da8 100644
--- a/meta/3rd/OpenResty/library/resty.string.lua
+++ b/meta/3rd/OpenResty/library/resty.string.lua
@@ -1,6 +1,75 @@
---@meta
-resty_string={}
-function resty_string.to_hex(s) end
-resty_string._VERSION="0.11"
-function resty_string.atoi(s) end
-return resty_string \ No newline at end of file
+
+--- OpenResty string functions.
+--- https://github.com/openresty/lua-resty-string
+local str = {
+ _VERSION = "0.14",
+}
+
+
+--- Encode byte string in hexidecimal.
+---
+--- This is most useful for retrieving a printable string from a checksum
+--- result.
+---
+--- Usage:
+---
+---```lua
+--- local str = require "resty.string"
+--- local md5 = require "resty.md5"
+---
+--- local sum = md5:new()
+--- sum:update("hello")
+--- sum:update("goodbye")
+--- local digest = sum:final()
+--- print(str.to_hex(digest)) --> 441add4718519b71e42d329a834d6d5e
+---```
+---@param s string
+---@return string hex
+function str.to_hex(s) end
+
+--- Convert an ASCII string to an integer.
+---
+--- If the string is not numeric, `-1` is returned.
+---
+--- Usage:
+---
+---```lua
+--- local str = require "resty.string"
+--- print(str.atoi("250")) --> 250
+--- print(str.atoi("abc")) --> -1
+---```
+---
+---@param s string
+---@return number
+function str.atoi(s) end
+
+
+--- A lua-resty-string checksum object.
+---@class resty.string.checksum : table
+local checksum = {
+ _VERSION = str._VERSION,
+}
+
+--- Create a new checksum object.
+---@return resty.string.checksum?
+function checksum:new() end
+
+--- Add a string to the checksum data.
+---
+--- This can be called multiple times.
+---
+---@param s string
+---@return boolean ok
+function checksum:update(s) end
+
+--- Calculate the final checksum.
+---@return string? digest
+function checksum:final() end
+
+--- Reset the checksum object.
+---@return boolean ok
+function checksum:reset() end
+
+
+return str \ No newline at end of file