Thursday, January 11, 2007

Base 64 Encoding

Base 64 encoding is a method used in email systems. The email systems that where developed back in the time of Arpanet, where designed to support only Letters (A-Z,a-z) , Numbers (0-9) and some limited puncutation marks. So inorder to transfer files which can contain more than characters and digits (for eg,a picture.jpg file), Base 64 Encoding is used.

The Encoding
Base 64 encoding, as the name suggests, has 64 different characters to represent all the 255 characters in the ASCII code. 64 different characters implies 6 bits as the word length. (no: of bits to represent a character)(2^6=64). So the encoding method is to group the binary data in groups of 6 bits.


Now the grouped 6 bits words are represented by letters, digits and punctuations. A table is defined to denote the mappings of the bit pattern to a corresponding character. Here is a sample of base64 encoding:


which stands for This is an example of base64 encoding.
You can find out more about this on google


Google Cookie
Base64 encoding is used in more than email systems, it is used in URL encoding of binary data. Those using google mail will have seen a stream of letters on their address bar. This base64 encoding of data. Google cookie or in short Gookie also use Base64 encoding to store data. The SID is a base64 encoding.

Similarly Orkut cookie structure is as follows:

INF=0:SET=:LNG=1:CNT=91:RM=0:USR=[Base64 of your email]:

Have more information on this? Leave a comment...

PHP Code/Functions
PHP base64 functions are :
  $ret = base64_encode($str);
  $ret = base64_decode($str);


Elite Student said...

What is SID??

Anonymous said...

what is "SID"

Arun Prabhakar said...

stands for Session ID

It is just a unique ID that is assigned by the server to you, to differentiate you from all those who are logged in.

Anonymous said...

can u explain more to me?
is it static or dynamic/changes everytime we login? is it in any way related to xid? is the session id shown anywhere realtime? is SID only used in cookies?

Arun Prabhakar said...

SID's are always dynamic
although some parts remain static like parts that store your username. But there is always a dynamic part that adds the security.

SID sometimes appear in the URL, other that in cookie. Based on the server and scripts on it can appear anywhere else...

What do you mean by XID ?

Anonymous said...


profile id is xid.

u said sid is dynamic all the time thats impossible since i used a cookie to login orkut multiple times for nearly a month without needing password and ya no changes to any part of the cookie not even the sid part.

if the sid part is dynamic then the cookie would have been how come?

Anonymous said...

oops sorry xid is not orkut pref its something else..