blob: e9852da87868022484b59a9070c1115c43617d7a (
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
--- 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
|