Base64-encode string (string.base64_encode)
Declaration
b64 = string.base64_encode(data)
Parameters
- data
string. Original string (or binary data).
Returns
- b64
string. Base64-encoded text.
Description
Base64-encode a string (or binary data).
Keywords: image Base64, file Base64, data Base64, binary Base64
Example
-- Capture a screen region as png, then base64-encode
b64s = screen.image(0, 0, 100, 100):png_data():base64_encode()
-- Read a file then base64-encode
b64s = file.reads('/var/mobile/1.png'):base64_encode()
Note: Uses functions outside of this chapter: screen.image
, :png_data
, file.reads