hex

package
v0.0.0-...-0c45383 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

README

hex

Lua module for encoding/hex

Usage

Encoding
local hex = require("hex")

s = hex.RawStdEncoding:encode_to_string("foo\01bar")
print(s)
Zm9vAWJhcg

s = hex.StdEncoding:encode_to_string("foo\01bar")
print(s)
Zm9vAWJhcg==

s = hex.RawURLEncoding:encode_to_string("this is a <tag> and should be encoded")
print(s)
dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA

s = hex.URLEncoding:encode_to_string("this is a <tag> and should be encoded")
print(s)
dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA==

Decoding
local hex = require 'hex'

decoded, err = hex.decode_string("666f6f62617262617a")
assert(not err, err)
print(decoded)
foobar

encoded = hex.encode_to_string(decoded)
print(encoded)
666f6f62617262617a

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeString

func DecodeString(L *lua.LState) int

DecodeString decodes the encoded string with the encoding

func EncodeToString

func EncodeToString(L *lua.LState) int

EncodeToString decodes the string with the encoding

func LVHexDecoder

func LVHexDecoder(L *lua.LState, reader io.Reader) lua.LValue

LVHexDecoder creates a new Lua user data for the hex decoder

func LVHexEncoder

func LVHexEncoder(L *lua.LState, writer io.Writer) lua.LValue

LVHexEncoder creates a new Lua user data for the hex encoder

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func NewDecoder

func NewDecoder(L *lua.LState) int

func NewEncoder

func NewEncoder(L *lua.LState) int

func Preload

func Preload(L *lua.LState)

Preload adds hex to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local hex = require("hex")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL