lights FAQ Forum   github.com/luapower/libb64
libb64

Internet Formats
libb64
expat
genx
cjson

libb64

base64 encoding & decoding


local b64 = require'libb64'

FFI binding of libb64, a fast base64 encoder and decoder by Chris Venter.

b64.encode(s[, size]) -> s
b64.decode(s[, size]) -> s
b64.encode(cdata, size) -> s
b64.decode(cdata, size) -> s

Encode/decode a string or cdata to a string.

b64.encode_tobuffer(s, [size], out_buf, out_size) -> bytes_written
b64.decode_tobuffer(s, [size], out_buf, out_size) -> bytes_written
b64.encode_tobuffer(cdata, size, out_buf, out_size) -> bytes_written
b64.decode_tobuffer(cdata, size, out_buf, out_size) -> bytes_written

Encode/decode a string or cdata to a buffer.

  • encoding needs a buffer of at least size * 2 + 3 bytes
  • decoding needs a buffer of at least math.floor(size * 3 / 4) bytes

TODO

Stream-like interface similar to zlib's inflate/deflate.
Benchmark against this pure ffi implementation1.


Last updated: 21 months ago | Edit on GitHub

Pkg type:Lua+ffi
Version: r2-22-g4a9ccff
Last commit:
License: PD
Import ver: 1.2
Requires: luajit 
Required by: none

Top