base64

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

README

base64 GoDoc

Lua module for encoding/base64

Usage

Encoding
local base64 = require("base64")

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

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

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

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

Decoding
local base64 = require("base64")

s, err = base64.RawStdEncoding:decode_string("Zm9vAWJhcg")
assert(not err, err)
print(s)
foobar

s, err = base64.StdEncoding:decode_string("Zm9vAWJhcg==")
assert(not err, err)
print(s)
foobar

s, err = base64.RawURLEncoding:decode_string("dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA")
assert(not err, err)
print(s)
this is a <tag> and should be encoded

s, err = base64.URLEncoding:decode_string("dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA==")
assert(not err, err)
print(s)
this is a <tag> and should be encoded

Documentation

Overview

Package base64 implements base64 encode/decode functionality for lua.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBase64Encoding

func CheckBase64Encoding(L *lua.LState, n int) *base64.Encoding

CheckBase64Encoding checks the argument at position n is a *base64.Encoding

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 LVBase64Decoder

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

func LVBase64Encoder

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

func LVBase64Encoding

func LVBase64Encoding(L *lua.LState, encoding *base64.Encoding) lua.LValue

LVBase64Encoding converts encoding to a UserData type for lua

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 NewEncoding

func NewEncoding(L *lua.LState) int

func Preload

func Preload(L *lua.LState)

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

local yaml = require("yaml")

Types

This section is empty.

Jump to

Keyboard shortcuts

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