utils.base64encode

Encode a string with base-64 encoding

Prototype

s = utils.base64encode (s [, linebreaks])

Description

Encodes the string 's' in base64 encoding (suitable for emails etc.). If 'linebreaks' is true, there will be a carriage return/linefeed every 76 characters. The string 's' may contain the null byte (ie. hex 00). Otherwise, this is the same behaviour as the world.Base64Encode function.

eg.

print (utils.base64encode ("Nick Gammon")) --> TmljayBHYW1tb24=
The output string will be 4/3 times as large as the input string, plus some possible padding to make up the result to a multiple of 4 (the padding character is "="). Also, if you request linebreaks there will be a further 2 byte for every 76 bytes output (that is, every 57 bytes of input). The default is to not have linebreaks.

Lua functions

Topics