-- Mock implementation of resty.sha256 for testing -- Uses system sha256sum command since we don't have OpenResty libraries local sha256 = {} sha256.__index = sha256 function sha256:new() local obj = { buffer = "" } setmetatable(obj, sha256) return obj end function sha256:update(data) self.buffer = self.buffer .. data end function sha256:final() -- Use sha256sum command to compute hash local handle = io.popen("echo -n '" .. self.buffer:gsub("'", "'\\''") .. "' | sha256sum") local result = handle:read("*a") handle:close() -- Parse hex string into binary local hex = result:match("^(%x+)") local binary = {} for i = 1, #hex, 2 do table.insert(binary, string.char(tonumber(hex:sub(i, i+1), 16))) end return table.concat(binary) end return sha256