📄 base64.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>BASE64 encoding</title>
<link REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
</head>
<body>
<a href="./index.htm">CONTENTS</a>
<h3>BASE64 encoding</h3>
<p>
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.
</p>
<p>
J-Painter uses BASE64 encoding to <a href="saving.htm#javascript">return image data to JavaScript</a>,
post them to the server using <a href="saving.htm#post">standrad post request</a>, or accept an image
file via the <a href="placing.htm#DrawCanvas">canvas</a> parameter "image".</p>
<p>Encoding example:</p>
<p>This image <img src="mail.png" > is retrieved from a binary file.
BASE64 encoded version of this file looks as follows:</p>
<pre>iVBORw0KGgoAAAANSUhEUgAAACAAAAATBAMAAAADuhLEAAAABGdBTUEAALGP
C/xhBQAAAAFzUkdCAdnJLH8AAAAPUExURYSEhP///wAAAP//AP8AACykMFsA
AABsSURBVHjahdDBDcMwDENRWhsw9AJRuwCBLuAi+8+UQ+rGTg75NwkPECBg
LlDmAuBUoCyZfapbm4Tr1gJlybVvPt/XKMz6boHyX4iWBmGKdBf5i6cwSVpX
4fGKnoRpqQsdV+1TmLYkBW4Pyks7gc8WIpISYokAAAAASUVORK5CYII=</pre>
<p>You can find the encoding technique here: <a href="http://www.ietf.org/rfc/rfc1521.txt" target="blank">http://www.ietf.org/rfc/rfc1521.txt</a>,
but most likely you needn't know them because many server-side scripting languages support functions for BASE64 encoding/decoding.
</p>
<ul><li>Did you know that you can use BASE64 to keep images in text fields of a database,<br>
and even save them in the database using SQL statements ?</li></ul>
<h4>How to decode BASE64 encoded data in different scripting languages.</h4>
<p><b>PHP</b></p>
<p>PHP has built in functions for BASE64 encoding and decoding:</p>
<pre>
base64_decode();
base64_encode();
</pre>
<hr>
<p><b>ASP.NET</b></p>
Use the function:
<pre>
System.Convert.FromBase64String(baseString);
</pre>
<hr>
<p><b>ASP</b></p>
<p>ASP has not built in functions for BASE64 decoding, but
you can find a nice implementation in VBScript here
<a href="http://www.pstruh.cz/tips/detpg_Base64.htm" target="_blank">http://www.pstruh.cz/tips/detpg_Base64.htm</a>
</p>
<hr>
<p><b>Java</b></p>
<p>There are a lot of BASE64 encoding/decoding implementations in Java.
For example, you may use my own implementation <a href="Base64.java" target="_blank" ><code>Base64.java</code></a>.
This file is located in the JSP example directory.
</p>
<hr>
<p><b>Perl</b></p>
<p>For BASE64 decoding use the function</p>
<pre>MIME::Base64::decode($encoded)</pre>
<hr>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -