package
0.5.0
Repository: https://github.com/vadv/gopher-lua-libs.git
Documentation: pkg.go.dev

# 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

# Functions

CheckBase64Encoding checks the argument at position n is a *base64.Encoding.
DecodeString decodes the encoded string with the encoding.
EncodeToString decodes the string with the encoding.
Loader is the module loader function.
No description provided by the author
No description provided by the author
LVBase64Encoding converts encoding to a UserData type for lua.
No description provided by the author
No description provided by the author
No description provided by the author
Preload adds yaml to the given Lua state's package.preload table.