BASE64 encoding CONTENTS

BASE64 encoding

BASE64 encoding performs any binary data as text (using only printable characters). Such text representation allows to pass binary data via a channel or save to a storage intended for text only, for example: e-mail software uses BASE64 encoding to hold attached files.

The editor uses BASE64 encoding to return image data to JavaScript or post them to the server using standrad post request.

Encoding example:

This image is retrieved from the binary file. BASE64 encoded version of this file looks as follows:

iVBORw0KGgoAAAANSUhEUgAAACAAAAATBAMAAAADuhLEAAAABGdBTUEAALGP
C/xhBQAAAAFzUkdCAdnJLH8AAAAPUExURYSEhP///wAAAP//AP8AACykMFsA
AABsSURBVHjahdDBDcMwDENRWhsw9AJRuwCBLuAi+8+UQ+rGTg75NwkPECBg
LlDmAuBUoCyZfapbm4Tr1gJlybVvPt/XKMz6boHyX4iWBmGKdBf5i6cwSVpX
4fGKnoRpqQsdV+1TmLYkBW4Pyks7gc8WIpISYokAAAAASUVORK5CYII=

You can find the encoding technique here: http://www.ietf.org/rfc/rfc1521.txt, but most likely you needn't know it because many server-side scripting languages support functions for BASE64 encoding/decoding.

How to decode BASE64 encoded data in different scripting languages.

PHP

PHP has built in functions for BASE64 encoding and decoding:

base64_decode();
base64_encode();

ASP.NET

Use the function:
System.Convert.FromBase64String(baseString);

Java

There are a lot of BASE64 encoding/decoding implementations in Java. For example, you may use my own implementation Base64.java.


ASP (classic)

ASP has not built in functions for BASE64 decoding, but you can find a nice implementation in VBScript here http://www.pstruh.cz/tips/detpg_Base64.htm


Perl

For BASE64 decoding use the function

MIME::Base64::decode($encoded)