blob: 7e627ef615416df633c53a21e7663451fa6c81bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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<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
|