Unofficial LSL Reference

[[articles:base64]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

articles:base64 [2015-02-04 11:32 SLT]
sei lsl:base64 renamed to articles:base64 (Relocate)
articles:base64 [2015-07-10 04:15 SLT] (current)
sei Add nav
Line 1: Line 1:
 +$nav
 =====Base64===== =====Base64=====
  
-Base64 is one way of storing sequences of characters in strings, that represent a sequence of bytes.+Base64 is one way of storing sequences of characters in strings, that represent a sequence of bytes. It's similar to hexadecimal,​ which provides 4 bits per character, and thus it needs 2 characters per byte. Base64 is more compact: with base64 only 4 characters are needed for every 3 bytes, or ~1.333 characters per byte on average.
  
 The representation uses the characters A to Z, a to z, 0 to 9, the plus sign (+) and the slash (/), in that order. Each character represents a 6-bit binary number from ''​000000''​ to ''​111111'',​ which is part of a byte. So A represents ''​000000'',​ B ''​000001'',​ ..., Z ''​011001'',​ a ''​011010'',​ ..., z ''​110011'',​ 0 ''​110100'',​ ..., 9 ''​111101'',​ + represents ''​111110'',​ and finally / represents ''​111111''​. The representation uses the characters A to Z, a to z, 0 to 9, the plus sign (+) and the slash (/), in that order. Each character represents a 6-bit binary number from ''​000000''​ to ''​111111'',​ which is part of a byte. So A represents ''​000000'',​ B ''​000001'',​ ..., Z ''​011001'',​ a ''​011010'',​ ..., z ''​110011'',​ 0 ''​110100'',​ ..., 9 ''​111101'',​ + represents ''​111110'',​ and finally / represents ''​111111''​.
Line 16: Line 17:
  
 which is the byte sequence 0xCF, 0xDF, 0x80. Therefore we can say that the Base64 string "​z9+A"​ represents the byte sequence 0xCF 0xDF 0x80. which is the byte sequence 0xCF, 0xDF, 0x80. Therefore we can say that the Base64 string "​z9+A"​ represents the byte sequence 0xCF 0xDF 0x80.
- 
-It's more compact than hexadecimal,​ which provides 4 bits per character, and thus it needs 2 characters per byte. With base64 only 4 characters are needed for every 3 bytes, or ~1.333 characters per byte on average. 
  
 The standard that specifies how Base64 is encoded requires that Base64 strings have a number of characters that is a multiple of four. When it is not, equal signs (=) are appended until it is. LSL is permissive with respect to padding, and accepts unpadded strings. When it generates Base64 strings, it generates them with padding. The standard that specifies how Base64 is encoded requires that Base64 strings have a number of characters that is a multiple of four. When it is not, equal signs (=) are appended until it is. LSL is permissive with respect to padding, and accepts unpadded strings. When it generates Base64 strings, it generates them with padding.