|LSL Portal||Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials|
About Base64 encoding
Base64 conversion expands three bytes of arbitrary binary data into four bytes of common ASCII characters in a completely reversible algorithm. It is generally used to convert binary data to strings so they can be sent across a text interface where ASCII control characters might be misinterpreted as end of string (\0) newline (\n) or otherwise not be transferred properly to the receiving process. In LSL this might be used to store binary data in an object's description, break data into bytes for cryptographic processing, or send data from one process to another using chat or linked messages.
Base64 input can be any sequence of bytes, the output consists exclusively of uppercase and lowercase letters, digits and the plus (+), slash (/) and equals (=) characters. Conversion to Base64 is done in blocks of three bytes (24 bits), padded if needed. These twenty-four bits are split into four six bit numbers which become an index to the conversion key ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") and written out as the eight bit ASCII character. Since the data is converted three bytes at a time, zero one or two equals characters are added to indicate how much padding was done in the last block. See the Wikipedia article for more information.
String and integer data in Base64.
|12345 (as an integer)||AAAwOQ==|