diff options
| author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2026-06-03 02:16:04 +0200 |
|---|---|---|
| committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2026-06-03 02:16:04 +0200 |
| commit | 4a79d7220f753cc9e26a2812da131218b46b6c1c (patch) | |
| tree | c0631982a2584222299f55d3b2865b0cdc6d957c /common.lua | |
| parent | f08683a3775989e749237cd001a8eaf3193d1684 (diff) | |
| download | r6p-4a79d7220f753cc9e26a2812da131218b46b6c1c.tar.xz | |
vendor json library
Diffstat (limited to 'common.lua')
| -rw-r--r-- | common.lua | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1,3 +1,6 @@ +local base64 = require("vendor.base64") +local json = require("vendor.JSON") + local table_unpack = table.unpack or unpack local function rand_string(n) local b = {} @@ -7,8 +10,26 @@ local function rand_string(n) return string.char(table_unpack(b)) end +local function base64_dec(x) + local succ, dec = pcall(base64.decode, x) + if succ then return dec end +end + +local function json_dec(x) + local succ, dec = pcall(json.decode, json, x) + if succ then return dec end +end + +local function json_enc(x) + return json:encode(x) +end + return { rand_string = rand_string, + base64_dec = base64_dec, + base64_enc = base64.encode, + json_dec = json_dec, + json_enc = json_enc, default_match_addr = "ivy.vlhl.dev:18252", gameid_len = 8, secret_len = 4, |
