<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>base64 &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/base64/</link>
	<description>Feed of posts on WordPress.com tagged "base64"</description>
	<pubDate>Sun, 29 Nov 2009 09:14:34 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Sobre base64. Para que usarlo, para que no, y como manejarlo en .net y Asp.Net]]></title>
<link>http://varionet.wordpress.com/2009/11/06/sobre-base64-para-que-usarlo-para-que-no-y-como-manejarlo-en-net-y-asp-net/</link>
<pubDate>Fri, 06 Nov 2009 04:01:31 +0000</pubDate>
<dc:creator>Alejandro Hernández</dc:creator>
<guid>http://varionet.wordpress.com/2009/11/06/sobre-base64-para-que-usarlo-para-que-no-y-como-manejarlo-en-net-y-asp-net/</guid>
<description><![CDATA[¿Que es base64? Base64 no es en principio otra cosa mas que un sistema numérico, el cual debido a su]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>¿Que es base64?</strong></p>
<p>Base64 no es en principio otra cosa mas que un sistema numérico, el cual debido a sus características se emplea en muchos ámbitos de la informática para representar información binaria.</p>
<p>Todos los sistemas de numeración tienen una lista de símbolos que utilizan para representar valores, por ejemplo:</p>
<p>Binario: &#8216;01&#8242;<br />
Decimal: &#8216;0123456789&#8242;<br />
Hexadecimal: &#8216;0123456789ABCDEF&#8217;<br />
y para base64 el conjunto es:<br />
&#8216;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/&#8217;</p>
<p>Como vemos, es un subconjunto de ASCII, y tiene como particularidad que todos sus caracteres son imprimibles, de hecho 64 es la mayor potencia de 2 que permite ser representada por un subconjunto de caracteres ASCII imprimibles, por eso, si pasamos cualquier información a su representación de base64, tenemos la seguridad de que no tendremos problemas al transmitirla, almacenarla o leerla, incluso aunque esta contega los más remotos caracteres unicode, una imagen o un mp3, ya que para convertir algo a base64 trataremos directamente con los bits.</p>
<p><strong>¿Como codificamos en base64?</strong></p>
<p>Veamos (en este ejemplo flagrantemente <a href="http://es.wikipedia.org/wiki/Base64" target="_blank">robado de Wikipedia</a>) como se codifica la palabra “Man”.</p>
<table border="1">
<tbody>
<tr>
<td>Texto de entrada</td>
<td colspan="8" align="center"><strong>M</strong></td>
<td colspan="8" align="center"><strong>a</strong></td>
<td colspan="8" align="center"><strong>n</strong></td>
</tr>
<tr>
<td>ASCII</td>
<td colspan="8" align="center">77</td>
<td colspan="8" align="center">97</td>
<td colspan="8" align="center">110</td>
</tr>
<tr>
<td>Bits</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>Índice</td>
<td colspan="6" align="center">19</td>
<td colspan="6" align="center">22</td>
<td colspan="6" align="center">5</td>
<td colspan="6" align="center">46</td>
</tr>
<tr>
<td>Resultado en Base64</td>
<td colspan="6" align="center"><strong>T</strong></td>
<td colspan="6" align="center"><strong>W</strong></td>
<td colspan="6" align="center"><strong>F</strong></td>
<td colspan="6" align="center"><strong>u</strong></td>
</tr>
</tbody>
</table>
<p>Tenemos que la M es en ASCII el caracter 77 (01001101 en binario), y como el primer paso para nuestra tarea es convertir la información de origen en bits (más sobre esto en un momento), transformamos toda la cadena en una secuencia de unos y ceros, los cuales tomamos en grupos de a seis.</p>
<p>El primero de estos grupos (010011) representa 19, y si tomamos la posición 19 en la lista de símbolos de base64 (empezando a contar desde cero, claro) obtenemos la T, y continuando con este algoritmo llegamos al resultado “TWFu”.</p>
<p><strong>Caracteres de Relleno</strong></p>
<p>base64 se codifica tomando los bytes de tres como entrada en cuatro sextetos, o sea de a 24 bits. Cuando esta cantidad no coincide, completamos con el caracter de relleno “=” los sextetos restantes.</p>
<p>Por ejemplo, si hubiéramos codificado solamente el texto “Ma”, veríamos que no coincide la cantidad de octetos con la de sextetos, luego de “TW” me quedaría 0001, por lo que completo con ocho ceros y obtengo “TWE”. El sexteto vacío que queda se completa con el caraceter “=” quedando como resultado: “TWE=”</p>
<p>Hasta aquí como se codifica. De la misma manera, podría codificar un archivo ejecutable, una imagen, archivos de sonido o simplemente como en este caso, Texto Plano.</p>
<p>Ooops, acabo de decir “texto plano”, pero como bien dice <a href="http://www.joelonsoftware.com/articles/Unicode.html" target="_blank">Joel Spolsky</a> (<a href="http://es.wikipedia.org/wiki/TANSTAAFL" target="_blank">parafraseando</a> a famoso <a href="http://es.wikipedia.org/wiki/Milton_Friedman" target="_blank">economista</a> que parafraseaba a conocido <a href="http://es.wikipedia.org/wiki/Robert_A._Heinlein" target="_blank">escritor de ciencia ficción</a>): “No existe tal cosa como el texto plano”. Y acá es donde entra a fastidiarnos la palabra “Encoding”.</p>
<p><strong>Encoding</strong></p>
<p>La representación lógica de una cadena de texto, como puede serlo un String de .net, se puede convertir a bits de muchas maneras. No es lo mismo la representación binaria de texto en ASCII que en Unicode, al respecto recomiendo encarecidamente leer el citado post de Joel Spolsky, pero lo que quiero destacar ahora a los efectos prácticos de comprender el código es que, cuando trabamos con texto, este es para nosotros la representación <em>lógica</em> de la información, la cual se perderá al momento de trabajar directramente con los bits, y como la conversión de esta información lógica a bits puede realizarse de muchas maneras distintas, debemos tener control de este paso al momento de codificar y decodificar texto en y desde base64.</p>
<p><strong>Base64 en .net</strong></p>
<p>Para convertir texto a bytes .net nos ofrece la clase abstracta Encoding y sus derivados concretos, en el ejemplo utilizaremos UTF8Encoding. Si no necesitamos usarlas en grandes iteraciones, podemos obtener instancias de estas clases desde las propiedades estáticas que nos da la clase Encoding, (.UTF8, .UTF7, .ASCII).</p>
<p>Y para obtener los bytes utilizamos el método GetBytes, dado un string “s”:</p>
<pre style="border-left:1px solid gainsboro;border-bottom:1px solid gainsboro;background-image:none;line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#0000ff;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Encoding</span></span><span style="font-size:small;"><span style="color:#000000;">.UTF8.GetBytes(s)</span></span></span></span></span></span></span></span></span></pre>
<p>Estos bytes se los pasamos a Convert.ToBase64String:</p>
<pre style="border-left:1px solid gainsboro;border-bottom:1px solid gainsboro;background-image:none;line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#0000ff;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">String</span></span><span style="color:#000000;font-size:small;"> b64 = </span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Convert</span></span><span style="color:#000000;font-size:small;">.ToBase64String(</span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Encoding</span></span><span style="font-size:small;"><span style="color:#000000;">.UTF8.GetBytes(s));</span></span></span></span></span></pre>
<p>y a la inversa, mediante el método GetString de la misma clase de Encoding que hayamos utilizado en la conversión:</p>
<pre style="border-left:1px solid gainsboro;border-bottom:1px solid gainsboro;background-image:none;line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#0000ff;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">String</span></span><span style="color:#000000;font-size:small;"> s = </span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Encoding</span></span><span style="color:#000000;font-size:small;">.UTF8.GetString(</span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Convert</span></span><span style="font-size:small;"><span style="color:#000000;">.FromBase64String(b64));</span></span></span></span></span></span></span></pre>
<p><strong>URLTokenEncode, base64 en ASP.NET</strong></p>
<p>Utilizar parámetros codificados en base64 en un query string nos aporta la seguridad de que no tendremos problemas con los caracteres reservados por HTML, así como la ofuscación de la información ante los usuarios, pero nos encontramos ante el problema de los símbolos “+”, “/”  y “=” que tienen un significado dentro de una URI.</p>
<p>Ante esta limitación .net nos da una alternativa a la codificación clásica mediante el método estático UrlTokenEncode de la clase HttpServerUtility, en System.Web:</p>
<pre style="border-left:1px solid gainsboro;border-bottom:1px solid gainsboro;background-image:none;line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#0000ff;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">String</span></span><span style="color:#000000;font-size:small;"> b64=</span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">HttpServerUtility</span></span><span style="color:#000000;font-size:small;">.UrlTokenEncode(</span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Encoding</span></span><span style="font-size:small;"><span style="color:#000000;">.UTF8.GetBytes(s));</span></span><span style="font-size:small;"><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">
String</span></span><span style="color:#000000;font-size:small;"> s=</span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">Encoding</span></span><span style="color:#000000;font-size:small;">.UTF8.GetString(</span><span style="color:#2b91af;font-size:small;"><span style="color:#2b91af;font-size:small;">HttpServerUtility</span></span><span style="font-size:small;"><span style="color:#000000;">.UrlTokenDecode(b64));</span></span></span></span></pre>
<p>Con este método, los caracteres “+” y “/” son reemplazados por “-“ y “_” respectivamente y los simbolos “=” de complemento se reemplazan por un dígito numérico indicando la cantidad de los mismos, de esta manera la cadena “ûï¾x%óaxz” se códifica (en UTF8) como: “w7vDr8K+eCXDs2F4eg==” según el método estándar y con UrlTokenEncode “w7vDr8K-eCXDs2F4eg2”, donde el &#8220;2” final representa los “==” al final del resultado estándar y el “-“ reemplaza al “+”.</p>
<p>De esta manera obtenemos una cadena totalmente segura para utilizar en el ámbito web.</p>
<p><strong>Algunos hechos sobre base64</strong></p>
<ul>
<li>Base64 no es un método de encriptación. Si bien ofusca la información ante la simple vista no hace falta mucho conocimiento ni pericia para recuperar la información original.</li>
<li>Base64 “pesa” un 33% más que la información original. Esta ralación está dada por la relación 8 a 6 bits por caracter, (o sea, un caracter de base64 representa menos información que un caracter normal).</li>
<li>Aparte del nombrado Issue en su utilización en Web, en otros ámbitos también hay caracteres que se tornan problemáticos, por ejemplo en regular expressions, se suelen reemplazar “+” y “/” por “[“ y “]”. Observesé que la codificación que utiliza UrlTokenEncode no serviría en este caso ya que los “+” tienen  significado propio en Regular Expression, por lo que habría que escaparlos.</li>
<li>Insisto: No sirve para encriptar información. No utiliza claves ni certificados, la conversión a la información original es prácticamente directa y no está pensado para este fin.</li>
<li>Si podemos, en cambio, utilizarlo para guardar o transmitir información previamente cifrada que suele presentar caracteres problemáticos para ser transmitidos o almacenados.</li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Base64 Encode/Decode for LoadRunner]]></title>
<link>http://ptfrontline.wordpress.com/2009/09/30/base64-encodedecode-for-loadrunner/</link>
<pubDate>Wed, 30 Sep 2009 08:36:36 +0000</pubDate>
<dc:creator>Kim</dc:creator>
<guid>http://ptfrontline.wordpress.com/2009/09/30/base64-encodedecode-for-loadrunner/</guid>
<description><![CDATA[Recently I had the need to decode a Base64 string received from a server and in the process I create]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Recently I had the need to decode a Base64 string received from a server and in the process I created an include file that contains both Encode and Decode functions for base64. Use &#38; Abuse as you see fit! Enjoy!<!--more--><br />
Below is an example of how to use the base64.h include file</p>
<pre class="brush: cpp;">
# include &#34;base64.h&#34;
vuser_init()
{
 int res;
 // ENCODE
 lr_save_string(&#34;ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&#34;,&#34;plain&#34;);
 b64_encode_string( lr_eval_string(&#34;{plain}&#34;), &#34;b64str&#34; );
 lr_output_message(&#34;Encoded: %s&#34;, lr_eval_string(&#34;{b64str}&#34;) );

 // DECODE
 b64_decode_string( lr_eval_string(&#34;{b64str}&#34;), &#34;plain2&#34; );
 lr_output_message(&#34;Decoded: %s&#34;, lr_eval_string(&#34;{plain2}&#34;) );

 // Verify decoded matches original plain text
 res = strcmp( lr_eval_string(&#34;{plain}&#34;), lr_eval_string(&#34;{plain2}&#34;) );
 if (res==0) lr_output_message(&#34;Decoded matches original plain text&#34;);

 return 0;
}
</pre>
<p>And here&#8217;s the actual base64.h include file</p>
<pre class="brush: cpp;">
/*
Base 64 Encode and Decode functions for LoadRunner
==================================================
This include file provides functions to Encode and Decode
LoadRunner variables. It's based on source codes found on the
internet and has been modified to work in LoadRunner.

Created by Kim Sandell / Celarius - www.celarius.com
*/
// Encoding lookup table
char base64encode_lut[] = {
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q',
'R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h',
'i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y',
'z','0','1','2','3','4','5','6','7','8','9','+','/','='};

// Decode lookup table
char base64decode_lut[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,62, 0, 0, 0,63,52,53,54,55,56,57,58,59,60,61, 0, 0,
0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
15,16,17,18,19,20,21,22,23,24,25, 0, 0, 0, 0, 0, 0,26,27,28,
29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
49,50,51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };

void base64encode(char *src, char *dest, int len)
// Encodes a buffer to base64
{
  int i=0, slen=strlen(src);
  for(i=0;i&#60;slen &#38;&#38; i&#60;len;i+=3,src+=3)
  { // Enc next 4 characters
    *(dest++)=base64encode_lut[(*src&#38;0xFC)&#62;&#62;0x2];
    *(dest++)=base64encode_lut[(*src&#38;0x3)&#60;&#60;0x4&#124;(*(src+1)&#38;0xF0)&#62;&#62;0x4];
    *(dest++)=((i+1)&#60;slen)?base64encode_lut[(*(src+1)&#38;0xF)&#60;&#60;0x2&#124;(*(src+2)&#38;0xC0)&#62;&#62;0x6]:'=';
    *(dest++)=((i+2)&#60;slen)?base64encode_lut[*(src+2)&#38;0x3F]:'=';
  }
  *dest=#0; // Append terminator
}

void base64decode(char *src, char *dest, int len)
// Encodes a buffer to base64
{
  int i=0, slen=strlen(src);
  for(i=0;i&#60;slen&#38;&#38;i&#60;len;i+=4,src+=4)
  { // Store next 4 chars in vars for faster access
    char c1=base64decode_lut[*src], c2=base64decode_lut[*(src+1)], c3=base64decode_lut[*(src+2)], c4=base64decode_lut[*(src+3)];
    // Decode to 3 chars
    *(dest++)=(c1&#38;0x3F)&#60;&#60;0x2&#124;(c2&#38;0x30)&#62;&#62;0x4;
    *(dest++)=(c3!=64)?((c2&#38;0xF)&#60;&#60;0x4&#124;(c3&#38;0x3C)&#62;&#62;0x2):'';
    *(dest++)=(c4!=64)?((c3&#38;0x3)&#60;&#60;0x6&#124;c4&#38;0x3F):'';
  }
  *dest=#0; // Append terminator
}

int b64_encode_string( char *source, char *lrvar )
// ----------------------------------------------------------------------------
// Encodes a string to base64 format
//
// Parameters:
//		source    Pointer to source string to encode
//		lrvar     LR variable where base64 encoded string is stored
//
// Example:
//
//		b64_encode_string( &#34;Encode Me!&#34;, &#34;b64&#34; )
// ----------------------------------------------------------------------------
{
	int dest_size;
	int res;
	char *dest;
	// Allocate dest buffer
	dest_size = 1 + ((strlen(source)+2)/3*4);
	dest = (char *)malloc(dest_size);
	memset(dest,0,dest_size);
	// Encode &#38; Save
	base64encode(source, dest, dest_size);
	lr_save_string( dest, lrvar );
	// Free dest buffer
	res = strlen(dest);
	free(dest);
	// Return length of dest string
	return res;
}

int b64_decode_string( char *source, char *lrvar )
// ----------------------------------------------------------------------------
// Decodes a base64 string to plaintext
//
// Parameters:
//		source    Pointer to source base64 encoded string
//		lrvar     LR variable where decoded string is stored
//
// Example:
//
//		b64_decode_string( lr_eval_string(&#34;{b64}&#34;), &#34;Plain&#34; )
// ----------------------------------------------------------------------------
{
	int dest_size;
	int res;
	char *dest;
	// Allocate dest buffer
	dest_size = strlen(source);
	dest = (char *)malloc(dest_size);
	memset(dest,0,dest_size);
	// Encode &#38; Save
	base64decode(source, dest, dest_size);
	lr_save_string( dest, lrvar );
	// Free dest buffer
	res = strlen(dest);
	free(dest);
	// Return length of dest string
	return res;
}</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[HTML img with base64]]></title>
<link>http://lin80h.wordpress.com/2009/09/22/html-img-with-base64/</link>
<pubDate>Tue, 22 Sep 2009 07:52:13 +0000</pubDate>
<dc:creator>lin80h</dc:creator>
<guid>http://lin80h.wordpress.com/2009/09/22/html-img-with-base64/</guid>
<description><![CDATA[One guy asked me if there is way to insert image in internal HTML code without links in html code. I]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>One guy asked me if there is way to insert image in internal HTML code without links in html code. In first moment i answered now and where had many arguments that it is imposible. Then he after some hours of googling havent found any thing. After chating with other guy he told about base64 and img.</p>
<p>Here is example Insert this code in <code>&#60;img src=&#39;base64-code&#39;/</code>&#62; and all will work<br />
<code></p>
<p>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAfCAYAAAClDZ5ZAAAInUlEQVR4nFSLuw3CUBRDDz9FEZtQUDMGM9CQVViNESjZIKB8np59H0WioBSW7GN7c709Sl0fOVQVu+2eUgpZmTSODH1P17WkNPB+PWnuDafzhe+nJUpBDixjG4WxAnnOM7c9MRlZxJL15yFCmj9aenuSVt7T1nnV/QAAAP//zMjBCQAhEMXQMBn7b3NBSxC+B7cIc3mQ1kab/k1CAtuNinU/NVjzo5QQXusAAAD//8zPMRHAMAwEwZP+XIQ/Sk/CQS5MIsUCWFU06CIJMzAzROnk6sb18L2bquKHDw4AAAD//8zRsQ0AIAzEQIc8SOy/Z5iAhAKGoHV3spr7PSI9SJEl9HpzxzD6mKwIKjcY32EOAAAA///M0rENACAMA0E7BsH+m4aWiNCEHRjh9N9kgqrKW+uchBVCJpBEHxO+HBEbJJH5l+QCAAD//2JiZmaG5AVorLAwszAws0DFmJgYGJmYGRgZmRhYWTkYvn79xvD7108GRkamgXY3BgAAAAD//8zTsQHAIAzEQPEy7L9tTJcChmAG6aJSep2cOloYSY4PxqDmonez+yPJa2fxAwAA//9iYmKCZGiIh6AZH8pnYmZiYIImLWYWFobfv//CPcIwyJIWAAAA//9iYmJiYkCOFVYWNE8wMTIwMjIxMDOzMPz5+4/hx49vDIxMzAPtbgwAAAAA///MkrENADAMg2yS/y+u4g6RekMHDkDQgJ5MtyZR1REgvNgWlGayRezv1roAAAD//2JhYmJiYIZ7BOJYZmjdwcjEyMDIBPEIIyMTw38GRoafP38wMA7CpAUAAAD//2JhYmKExggTAwszE8M/JgYGZmZILDEyIjzByMjI8J+BkeHXr5+QSnGQAQAAAAD//2JhZISEPBMTEwMzCzMD0///SMmKEeoRRqjjGRl+//7FwMgw+DwCAAAA//9igYU4ExMjAwszE8P//wzQ2GBkYEAKeZhn/v6F1uyDDAAAAAD//2JhgLqXkZER3kSBOBohzgCNDQYGRoZ/f/8yINoog8dHAAAAAP//YoE5kJGBkYGZiZHh339YwoE5HgkwMjD8+/+P7o4kBgAAAAD//0Jpa0AKInqXRv8Z/v/7D227kW83AAAA//+sljEOwDAMAs807f/f2wEyWOnitSsSCIkbWG0OITgdeJQRHND3s/7BqiTW/WCJ5MWeizfqF6VQ5dkL2AAAAP//lJexCoAwEENf76z//6EOIlJa6/UclKLoYsYMbwghkAGnfxAzozl4c+4+PS1HVD9Bv+Scky5OSSvLPF0faEQ0vpphtlNyom6ZIIpIJDR7IA8AAAD//6SXMQrCQBRE3ybfFAqRSIiVeP8DxVJBG8sg2ewiu/9bZCEH8ATDY4o3I2aGqaJqpKTljyhmWkhKdmlLRP7mcJXjGyPPx8jrfqPtBvaHdpWxNJzOVxKQc6aud4T5TQyexX8IfkKk4dhfwG1T6QcAAP//pJc7CsJAGAYHdLWRgM/OIlU6G2uPbm1jJYKdaUQhKBiSKLi732+R4AW8wQxMM/0W2pDa3zYDRSHrUsN+EmA4N/j7RSRRlXeO+y3ZakOarYnB82oqimvO5XxglMzouSHl44b3H8bzJclUvOsn+WlHiIHJIu0CN74AAAD//2L5/w/iib9//zH8/QPxwN9//xj+/YPEyn8Y/f8/AyPDfwY2NnaKPMLICCnCf/38zsDCys4gr6zLwMTExPDh0zuGy6d3Mzy4dY7hz++fDIKiMgxWrvEMTMwsDOf2L2eQlNNiUNaxZeDhF2UQFJVl+PzxNcO/f7CqgIEBAAAA//+cmD0KwkAYBecz6w8qYiFYeQAhnbaWHiEHzhUEQRBiEYQIYpEQCbi+tTDxAHavHaYZnpPEW2rfDo/0VSp1EJ0RYRYYDEfttj97ywhBRK5P86y4XTO8f5FfjjR1SbzdM57OCRh19aAXOTa7hCI/cT6kLFdr7kXGZLb4ZRPABwAA//9i+vfvH8O/f5Ahmj/QIZu/f/9Bkte/fwzwpPf3LwMTIyMDBwcnRXXJ////GFjZ2BlYWNkZZBS1GA7vXMxw7fwBBg5ObgYJWTUGWSVdhjcvHjK8eHyT4dOHVwz3b5xkYGZhZeDhF2Vg4+BiuHJiIwMjAyMDv7A0AyMTMzR1MDIAAAAA//9igServ38Z/jAyQcer/jL8/YccK/+gY0dMDOwcXFiLSNJ8w8DALyDCYGDuwSCvYsDw4uldBmZmVgYhUVmGx3cvwZV9/fyOgZWNk4Hh/3+Gr5/fMsiqmjDw8oszcHALMDAyMUOaSwyQ0gsAAAD//2L6+w9pIO0PdMDrz19EjECT15+/vxnYWFkYODg4Gf7/+4fSDiM9ViCDGywsrAwi4nIM8ir6DJ8/vmb48vkdw/u3zxi4eAQY+AREGT69e8EgLCbPcP/mSQZObn4GNnYuBkExOQZWNg6o9YikDQAAAP//YvqHNDIIG/mDjOohxcr/fwx/fv9i4OBgZ2Dj4GT49+8fZdUhIwMDA7Ti/fP7FwM3ryCDqIQiw73rpxmEYQ5lYmYQEpNlYGD4z8AnKMHAwsrB8OvHN6R8i2okAAAA//9igcTGH4Y/f/8wMDAwICUtyPDmv39/GRj+/2f4/esnAz83NwMbKzvDr19fKPEGqp8YGRn+/PnNwC8kzqBn7gHpiUId+u//f4Y/v38xCEsoMfz69QOecrB1IwAAAAD//6yYMQqAQAwER9RK4dDS//9RuGQTi4ulnQ/YhYVpdsYQH66VCuvFK0RIJIn1m3adzMv6s9OayBDbfqAQZr3wdqIcmuR17vTZ8gAAAP//YoHFBvOfP5Dmyf//0JLrL7QY/svw/x/EI0JCItBuLhX9AfELJDn/+YNS5KMC/JYCAAAA//+CxsgfyKA1zCPQEe5/f/8y/Pv7h+Hf/38Mf3//YBAWEYVYQIMhU0YkkhwAAAAA//8DAP+qBMyfdCcoAAAAAElFTkSuQmCC</p>
<p></code><br />
It is way how to insert base64 converted image in your html code without external links or files.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[QSByYW50IGluIGJhc2U2NA==]]></title>
<link>http://avc1234567890.wordpress.com/2009/09/11/qsbyyw50igluigjhc2u2na/</link>
<pubDate>Fri, 11 Sep 2009 21:24:44 +0000</pubDate>
<dc:creator>deathgleaner</dc:creator>
<guid>http://avc1234567890.wordpress.com/2009/09/11/qsbyyw50igluigjhc2u2na/</guid>
<description><![CDATA[Q2FuJ3QgcmVhZCB0aGUgdGl0bGU/IE5vIHByb2JsZW0hIElmIHlvdSBoYWQgYW4gYXV0b21h dGljIGJhc2U2NCBlbmNvZGVyL2R]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Q2FuJ3QgcmVhZCB0aGUgdGl0bGU/IE5vIHByb2JsZW0hIElmIHlvdSBoYWQgYW4gYXV0b21h<br />
dGljIGJhc2U2NCBlbmNvZGVyL2RlY29kZXIgdGhlbiBsdWNreSB5b3UgYmVjdWFzZSB0aGUg<br />
bGFuZ3VhZ2Ugb2YgdGhpcyBibG9nIHBvc3QgaXMgZXhhY3RseSB0aGF0OiBiYXNlNjQuIEkg<br />
dGhpbmsgYmFzZTY0IGlzIGEgbGFuZ3VhZ2UgdXNlZCBieSB0aG9zZSBjb21wdXRlciBwcm9n<br />
cmFtbWluZyBuZXJkcywgYnV0IEknbSBub3Qgc3VyZS4gVGhlIHByb2dyYW0gSSdtIHVzaW5n<br />
IHRvIGVuY3J5cHQgdGhlc2UgbWVzc2FnZXMgaXMgY2FsbGVkIExpbmdvZXMuIEl0J3MgcnVu<br />
bmluZyBvbiBteSBmbGFzaCBkcml2ZSB0aHJvdWdoIFBvcnRhYmxlQXBwcy5jb20gbWVudS4g<br />
WWVhaCwgYW5kIHRoYXQncyBvbmx5IGF2YWlsYWJsZSBmb3IgV2luZG93cywgeW91IG1hY3Rh<br />
cmRzLiBTbyBxdWl0IGJlaW5nIGEgbWFjdGFyZCBhbmQgc3dpdGNoIChiYWNrKSB0byBXaW5k<br />
b3dzIGJlY2F1c2UgaXQncyB3YXkgYmV0dGVyIHRoYW4gTWFjcy4gQydtb24hIFlvdSBjYW4n<br />
dCBldmVuIHByZXNzIHRoZSAiZGVsZXRlIiBidXR0b24gdG8gZGVsZXRlIGZpbGVzIG9uIGEg<br />
TWFjISBUaGVuIHdoYXQncyB0aGUgZGVsZXRlIGJ1dHRvbiBmb3I/IEFuZCB5b3UgY2FuJ3Qg<br />
aG9sZCBkb3duIEN0cmwrbW91c2UgY2xpY2sgdG8gc2VsZWN0IGZpbGVzLiBXVEYgQXBwbGU/<br />
IElmIHlvdSd2ZSBub3RpY2VkLCB0aGlzIHBvc3QgY29udGFpbnMgcGVyZmVjdCBncmFtbWFy<br />
IHNvIHlvdSBjYW4gc3RpbGwgcmVhZCBpdC4gSSdtIG5vdCBzdXJlIGlmIEknbGwgZG8gYW55<br />
bW9yZSBiYXNlNjQgcmFudHMsIGJ1dCB0aGF0J3MgYWxsLg==</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Encriptacion base64 en Java]]></title>
<link>http://deoracleyjava.wordpress.com/2009/08/21/encriptacion-base64-en-java/</link>
<pubDate>Fri, 21 Aug 2009 22:54:56 +0000</pubDate>
<dc:creator>cintya1984</dc:creator>
<guid>http://deoracleyjava.wordpress.com/2009/08/21/encriptacion-base64-en-java/</guid>
<description><![CDATA[Hola a todos&#8230;.. Tuve la necesidad de encriptar unos datos en base64&#8230;. aquí les dejo un e]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hola a todos&#8230;..</p>
<p>Tuve la necesidad de encriptar unos datos en base64&#8230;. aquí les dejo un ejemplo, para esto yo utilizé una librería llamada base64 , la cual pueden descargarse <a href="http://mindprod.com/zips/base6419.zi&#60;/a&#62;p">aquí.</a></p>
<p>Hecho esto, agregar esta librería a su proyecto y lixto!!!</p>
<p>Este es el código de las clase:</p>
<p><strong>//Clase BAse64Ejemplo</strong></p>
<p>import com.mindprod.base64.Base64u;</p>
<p>public class Base64Ejemplo<br />
{<br />
public Base64Ejemplo()<br />
{<br />
}</p>
<p>public String datoCodificado(String datoCodificar)<br />
{<br />
String encoded=new String();<br />
try<br />
{<br />
byte[] sendBytes = datoCodificar.getBytes( &#8220;8859_1&#8243;/* encoding */ );<br />
Base64u base64 = new Base64u();<br />
base64.setLineLength( 72 );<br />
encoded = base64.encode( sendBytes );<br />
}<br />
catch(java.io.UnsupportedEncodingException e)<br />
{</p>
<p>}<br />
return encoded;<br />
}</p>
<p>public String datoDecodificado(String datoDecodificar)<br />
{<br />
String decoded=new String();<br />
try<br />
{<br />
Base64u base64 = new Base64u();<br />
base64.setLineLength( 72 );<br />
byte[] reconstitutedBytes = base64.decode(datoDecodificar);<br />
decoded =new String( reconstitutedBytes, &#8220;8859_1&#8243;/* encoding */ );<br />
}<br />
catch(java.io.UnsupportedEncodingException e)<br />
{</p>
<p>}<br />
return decoded;<br />
}</p>
<p>}</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Issue: Base64Encoding() in Java ME]]></title>
<link>http://azamjauhari.wordpress.com/2009/07/30/issue-base64encoding-in-java-me/</link>
<pubDate>Thu, 30 Jul 2009 10:32:25 +0000</pubDate>
<dc:creator>azamjauhari</dc:creator>
<guid>http://azamjauhari.wordpress.com/2009/07/30/issue-base64encoding-in-java-me/</guid>
<description><![CDATA[Considering using Base64Encoding() in Java ME for your mobile application? Read this: http://forums.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Considering using Base64Encoding() in Java ME for your mobile application? Read this:</p>
<p><a title="http://forums.sun.com/thread.jspa?threadID=5231025" href="http://forums.sun.com/thread.jspa?threadID=5231025" target="_blank">http://forums.sun.com/thread.jspa?threadID=5231025</a></p>
<p>In a nutshell, it may work flawlessly in emulators, but not on actual device!</p>
<p>You have been warned.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Developers Should Not Write Programs That Call sun Packages]]></title>
<link>http://rafacastanho.wordpress.com/2009/06/30/developers-should-not-write-programs-that-call-sun-packages/</link>
<pubDate>Tue, 30 Jun 2009 18:06:31 +0000</pubDate>
<dc:creator>Rafael Castanho</dc:creator>
<guid>http://rafacastanho.wordpress.com/2009/06/30/developers-should-not-write-programs-that-call-sun-packages/</guid>
<description><![CDATA[Recently I have a big f*cking bug because I forgot this LAW. Please developers, I saw in my search m]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Recently I have a big <del datetime="2009-06-30T17:53:21+00:00">f*cking</del> bug because I forgot this <em><strong>LAW</strong></em>.</p>
<p>Please developers, I saw in my search many and many examples in especial regarding <em>base64 conversions</em> and other stuffs using <code>sun.*</code> packages. <strong>AVOID</strong> this !</p>
<p>Please read the article below:<br />
<a href="http://java.sun.com/products/jdk/faq/faq-sun-packages.html">Why Developers Should Not Write Programs That Call &#8217;sun&#8217; Packages</a></p>
<p>You will find some warnings like:</p>
<ul>
<li>Different across OS platforms</li>
<li>One release to another, these classes may be <strong>removed</strong></li>
<li><strong>No documentation</strong> available for the sun.* classes</li>
<li>Java program that directly calls into sun.* packages is <strong>not guaranteed to work</strong></li>
<li>Programs that contain direct calls to the sun.* packages <strong>are not 100% Pure Java</strong></li>
</ul>
<p>and etc&#8230;</p>
<p>I&#8217;ll put here some easy example using <code>apache</code> libs to do a <strong>base64 conversion! </strong></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[8bit, quoted-printable, base64]]></title>
<link>http://m3dialuvrs.wordpress.com/2009/06/11/8bit-quoted-printablebase64/</link>
<pubDate>Thu, 11 Jun 2009 12:17:24 +0000</pubDate>
<dc:creator>onl9r</dc:creator>
<guid>http://m3dialuvrs.wordpress.com/2009/06/11/8bit-quoted-printablebase64/</guid>
<description><![CDATA[จำไว้ ถ้าจะส่งเมล์ผ่านเว็บ แม้จะ Encoding ด้วย UTF-8  แล้ว แต่มีตัวหนังสือบางตัว ยังจะโผล่ตัวอักษรแป]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>จำไว้ ถ้าจะส่งเมล์ผ่านเว็บ แม้จะ Encoding ด้วย UTF-8  แล้ว แต่มีตัวหนังสือบางตัว ยังจะโผล่ตัวอักษรแปลกๆมาอีกล่ะก็ <img class="aligncenter size-full wp-image-8" title="bad character" src="http://m3dialuvrs.wordpress.com/files/2009/06/badcharacter.jpg" alt="bad character" width="96" height="100" />ไปหาที่เปลี่ยน Content-Transfer-Encoding จาก 8bit เป็น quoted-printable, base64 ซะนะ</p>
<p><img class="aligncenter size-full wp-image-9" title="8bit2quoted" src="http://m3dialuvrs.wordpress.com/files/2009/06/8bit2quoted.jpg" alt="8bit2quoted" width="480" height="61" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[List of Swear Words in Base64 Language]]></title>
<link>http://deathgleaner.wordpress.com/2009/06/05/list-of-swear-words-in-base64-language-2/</link>
<pubDate>Fri, 05 Jun 2009 22:27:01 +0000</pubDate>
<dc:creator>deathgleaner</dc:creator>
<guid>http://deathgleaner.wordpress.com/2009/06/05/list-of-swear-words-in-base64-language-2/</guid>
<description><![CDATA[For those of you who have no idea what base64 is, it&#8217;s basically a standarized code. How it is]]></description>
<content:encoded><![CDATA[For those of you who have no idea what base64 is, it&#8217;s basically a standarized code. How it is]]></content:encoded>
</item>
<item>
<title><![CDATA[Encoding/Decoding Byte Arrays with Java]]></title>
<link>http://vertoda.wordpress.com/2009/04/14/encodingdecoding-byte-arrays-with-java/</link>
<pubDate>Tue, 14 Apr 2009 13:14:29 +0000</pubDate>
<dc:creator>martcon</dc:creator>
<guid>http://vertoda.wordpress.com/2009/04/14/encodingdecoding-byte-arrays-with-java/</guid>
<description><![CDATA[The simplest way to convert a byte array into a String in Java is to call the latter&#8217;s class c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="font-family:Book Antiqua;color:#999999;">The  simplest way to convert a byte array into a String in Java is to call the  latter&#8217;s class constructor. For example:</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">byte[]  theByteArray = new byte {1,2,3};</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">String  theString = new String(theByteArray);</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">However, a lot of byte data will not form a meaningful string  unless encoded. Encoding and decoding is not provided in the standard Java  packages. Encoding is provided in the sun.misc.* package but these should not be  used as classes under this package can be modified or disappear without warning  in new releases of Java. Fortunately, Apache have provided a solution in their  commons library. See <a href="http://commons.apache.org/index.html">http://commons.apache.org/index.html</a></span><span style="font-family:Book Antiqua;color:#999999;">.</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">We  will use Base64 encoding as an example. Base64 encodes every 3 bytes of input  into 4 bytes of output. It is used to encode photos or audio sent in emails and  for usernames and passwords used for webpage authentication. The following code  snippet illustrates how we convert a byte array into a Base 64  string:</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">//  Apache commons Import.</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">import  org.apache.commons.codec.binary.Base64;</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">public  class Base64Encoding {</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">// The  Base 64 Encoder.</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">private Base64 base64Encoder = new Base64();</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">public  void doEncoding(byte[] byteArray)</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">{</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;"> //  Using the Base 64 Encoder format the byte array as a Base64 String.</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;"><span style="font-size:x-small;"> byte[] base64ByteArray = this.base64Encoder.encode(byteArray);</span></span></p>
<p><span style="font-family:Book Antiqua;color:#999999;"><span style="font-size:x-small;"> String theString =  new String(base64ByteArray);</span></span></p>
<p><span style="font-family:Book Antiqua;color:#999999;"><span style="font-size:x-small;"> System.out.println(&#8220;The String is &#8221; + theString);</span></span></p>
<p><span style="font-family:Book Antiqua;color:#999999;"><span style="font-size:x-small;">}</span></span></p>
<p><span style="font-family:Book Antiqua;color:#999999;"><span style="font-size:x-small;">} </span></span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[decode base64 string with openssl]]></title>
<link>http://0xcb0.com/2009/04/12/decode-base64-string-with-openssl/</link>
<pubDate>Sun, 12 Apr 2009 10:58:35 +0000</pubDate>
<dc:creator>0xcb0</dc:creator>
<guid>http://0xcb0.com/2009/04/12/decode-base64-string-with-openssl/</guid>
<description><![CDATA[On OS X you can easily decode base64 strings with the openssl command openssl base64 -d -in &lt;(ech]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>On OS X you can easily decode base64 strings with the openssl command</p>
<blockquote><p>openssl base64 -d -in &#60;(echo &#8220;dGhpcyBpcyBhIHRlc3QKCg==&#8221;)</p></blockquote>
<p>just drop the &#8216;-d&#8217; if you want to encode things.</p>
<p>I found this <a href="http://www.macosxhints.com/article.php?story=20030721010526390" target="_blank">here</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[On Base64]]></title>
<link>http://pebbie.wordpress.com/2009/03/31/on-base64/</link>
<pubDate>Tue, 31 Mar 2009 16:47:00 +0000</pubDate>
<dc:creator>pebbie</dc:creator>
<guid>http://pebbie.wordpress.com/2009/03/31/on-base64/</guid>
<description><![CDATA[*duh, dah lama nggak update blog saking sibuknya (cari alesan)* Beberapa waktu yang lalu ada permint]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>*duh, dah lama nggak update blog saking sibuknya (cari alesan)*</p>
<p>Beberapa waktu yang lalu ada permintaan untuk melakukan <em>encoding/decoding</em> ke format <a href="http://en.wikipedia.org/wiki/Base64">base64</a>. karena waktu yang mendesak dan jumlah <em>item requirement</em> yang banyak maka alternatif pertama adalah mencari kode <em>public domain</em> di internet. ternyata tidak satupun yang bisa dipakai (pada saat yang sempit itu). hambatannya bermacam-macam, mulai dari hasil <em>encoding</em> yang tidak sesuai, atau hasil <em>decoding</em> yang beda dengan acuan. setelah duduk sebentar sambil <em>melototin</em> lagi halaman wikipedia yang mendeskripsikan aturan pengkodean basis64 akhirnya langkah terakhir malah bikin sendiri fungsi yang sesuai dengan spek (teks dari/ke base64, <em>binary</em>(variabel bertipe ataupun <em>byte stream</em>) dari/ke base64).</p>
<p>bagi yang berminat menggunakan, dipersilakan menggunakan kode berikut sebebas-bebasnya (pubdom as no warranty for using).<br />
<!--more--></p>
<pre class="brush: delphi;">(*
 * auth : Peb Ruswono Aryan
 * desc : base64 encoding/decoding for delphi
 *)
type
  tbytearr = array of byte;

{
	encode64 : Pointer x Nat --&gt; string
	desc: encode binary data to base64 message
}
function encode64( const v: Pointer; vsize: cardinal ): string;
const
  lut64             = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var
  tribyte           : array[0..2] of byte;
  p                 : PByteArray;
  ci, i             : cardinal;

  function enc3byteto4char( len: integer ): string;
  begin
    result := lut64[1 + tribyte[0] shr 2];
    result := result + lut64[1 + ( ( tribyte[0] and $03 ) shl 4 ) + ( tribyte[1] shr 4 )];
    if len &gt; 1 then
      result := result + lut64[1 + ( tribyte[1] and $0F ) shl 2 + ( tribyte[2] shr 6 )]
    else
      result := result + '=';
    if len &gt; 2 then
      result := result + lut64[1 + tribyte[2] and $3F]
    else
      result := result + '=';
  end;
begin
  p := PByteArray( v );
  ci := 0;
  repeat
    i := 0;
    while i &lt; 3 do begin
      if ci &gt;= vsize then break;
      tribyte[i] := p[ci];
      inc( ci );
      inc( i );
    end;
    result := result + enc3byteto4char( i );
  until ci &gt;= vsize;
end;

{
	decode64 : String --&gt; DynamicArray of byte
	desc: decode base64message to binary data (array of byte)
}
function decode64( msg: string ): TbyteArr;
var
  pb                : array of byte;
  lm, pi            : integer;
  len               : integer;

  function decodechar( c: char; var code: byte ): boolean;
  begin
    result := true;
    case c of
      'A'..'Z': code := ord( c ) - ord( 'A' );
      'a'..'z': code := ord( c ) - ord( 'a' ) + 26;
      '0'..'9': code := ord( c ) - ord( '0' ) + 52;
      '+': code := 62;
      '/': code := 63;
    else
      result := false;
    end;
  end;

  procedure decodeblock( blk: string );
  var
    t, i            : byte;
    w               : dword;
  begin
    w := 0;
    i := 0;
    while i &lt; 4 do begin
      if not decodechar( blk[i + 1], t ) then break;
      w := w shl 6 + t;
      inc( i );
    end;
    result[pi] := ( w shr 16 ) and $FF;
    inc( pi );
    if pi &gt;= len then exit;
    result[pi] := ( w shr 8 ) and $FF;
    inc( pi );
    if pi &gt;= len then exit;
    result[pi] := ( w and $FF );
    inc( pi );
  end;
begin
  len := length( msg ) * 3 div 4;
  lm := length( msg );
  if msg[lm] = '=' then dec( len );
  if msg[lm - 1] = '=' then dec( len );
  setlength( result, len );
  pi := 0;
  repeat
    decodeblock( copy( msg, 1, 4 ) );
    delete( msg, 1, 4 );
  until length( msg ) &lt;= 0;
end;

{
	encode64str : string --&gt; string
	desc: encode text string into base64 message
}
function encode64str( msg: string ): string;
var
  p                 : TByteArr;
  i                 : integer;
begin
  setlength( p, length( msg ) );
  for i := 0 to high( p ) do
    p[i] := ord( msg[i + 1] );
  result := encode64( @p[0], length( p ) );
end;

{
	decode64str : string --&gt; string
	desc: decode base64 message containing text
}
function decode64str( msg: string ): string;
var
  p                 : TByteArr;
  i                 : integer;
begin
  result := '';
  p := decode64( msg );
  for i := 0 to length( p ) do
    result := result + chr( p[i] );
end;</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[CONVIERTE texto→binario→hexa→base64→dec/char]]></title>
<link>http://kamikazikid.wordpress.com/2009/03/18/convierte-texto%e2%86%92binario%e2%86%92hexa%e2%86%92base64%e2%86%92decchar/</link>
<pubDate>Thu, 19 Mar 2009 05:14:30 +0000</pubDate>
<dc:creator>dhariuz</dc:creator>
<guid>http://kamikazikid.wordpress.com/2009/03/18/convierte-texto%e2%86%92binario%e2%86%92hexa%e2%86%92base64%e2%86%92decchar/</guid>
<description><![CDATA[Nunca t haz preguntado como se veria una palabra en codigo binario o hexadecimal, o haz querido acor]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:center;"><a href="codigobinario"><img class="aligncenter" src="http://2.bp.blogspot.com/_z-iV1gDJ-tw/RwIJSaGkalI/AAAAAAAAACc/OvwMOsto_8s/s320/codigo+binario.bmp" alt="" width="300" height="200" /></a></p>
<p>Nunca t haz preguntado como se veria una palabra en codigo binario o hexadecimal, o haz querido acortarte los pasos en esos problemas del flag register en ensamblador&#8230;.. yo si, palschou tiene una herramienta online que te permite convertir texto o numero a binario y visceversa.</p>
<p>kamikazikid en</p>
<p>binario</p>
<p>01101011 01100001 01101101 01101001 01101011 01100001 01111010 01101001 01101011 01101001</p>
<p>01100100</p>
<p>VISITA <a href="http://www.paulschou.com/tools/xlate/" target="_blank">binary translator</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Objective-C and HTTP Basic Authentication]]></title>
<link>http://davidjhinson.wordpress.com/2009/03/09/objective-c-and-http-basic-authentication/</link>
<pubDate>Mon, 09 Mar 2009 11:12:17 +0000</pubDate>
<dc:creator>davidjhinson</dc:creator>
<guid>http://davidjhinson.wordpress.com/2009/03/09/objective-c-and-http-basic-authentication/</guid>
<description><![CDATA[For all the really nice stuff Objective-C lets you do on the iPhone, there are many, many holes left]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>For all the really nice stuff Objective-C lets you do on the iPhone, there are many, many holes left for very common tasks.</p>
<p>One of those tasks is Base64 encoding.</p>
<p>Base64 encoding is used to convert binary data into text that can be transmitted using HTTP (like, say, for <a title="Embedding Images in Email Using Cocoa-Touch" href="http://davidjhinson.wordpress.com/2009/01/21/embedding-images-in-outbound-email-using-cocoa-touch/" target="_blank">embedding images in email</a>) or for somewhat obfuscating user ids and passwords to be sent &#8220;in the clear&#8221; over HTTP (like for Basic Authentication).</p>
<p>Without much further ado, I present one of a gagillion implementations of Base64 encoding in C:</p>
<blockquote><p><code>static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"<br />
"abcdefghijklmnopqrstuvwxyz"<br />
"0123456789"<br />
"+/";</code></p>
<p><code>int encode(unsigned s_len, char *src, unsigned d_len, char *dst)<br />
{<br />
unsigned triad;</code></p>
<p><code>for (triad = 0; triad &#60; s_len; triad += 3)<br />
{<br />
unsigned long int sr;<br />
unsigned byte;</code></p>
<p><code>for (byte = 0; (byte&#60;3)&#38;&#38;(triad+byte&#60;s_len); ++byte)<br />
{<br />
sr &#60;&#60;= 8;<br />
sr &#124;= (*(src+triad+byte) &#38; 0xff);<br />
}</code></p>
<p><code>sr &#60;&#60;= (6-((8*byte)%6))%6; /*shift left to next 6bit alignment*/</code></p>
<p><code>if (d_len &#60; 4) return 1; /* error - dest too short */</code></p>
<p><code>*(dst+0) = *(dst+1) = *(dst+2) = *(dst+3) = '=';<br />
switch(byte)<br />
{<br />
case 3:<br />
*(dst+3) = base64[sr&#38;0x3f];<br />
sr &#62;&#62;= 6;<br />
case 2:<br />
*(dst+2) = base64[sr&#38;0x3f];<br />
sr &#62;&#62;= 6;<br />
case 1:<br />
*(dst+1) = base64[sr&#38;0x3f];<br />
sr &#62;&#62;= 6;<br />
*(dst+0) = base64[sr&#38;0x3f];<br />
}<br />
dst += 4; d_len -= 4;<br />
}</code></p>
<p><code>return 0;</code></p>
<p><code>}</code></p></blockquote>
<p>And here is how one may transmit a user id and password (using NSURLConnection) to establish a connection using Basic Authentication:</p>
<blockquote><p><code>myApp.loginString    = (NSMutableString*)[[NSUserDefaults standardUserDefaults] stringForKey:kloginKey];<br />
myApp.passwordString = (NSMutableString*)[[NSUserDefaults standardUserDefaults] stringForKey:kpasswordKey];</code></p>
<p><code>NSMutableString *dataStr = (NSMutableString*)[@"" stringByAppendingFormat:@"%@:%@", myApp.loginString, myApp.passwordString];</code></p>
<p><code>NSData *encodeData = [dataStr dataUsingEncoding:NSUTF8StringEncoding];<br />
char encodeArray[512];</code></p>
<p><code>memset(encodeArray, '&#92;0', sizeof(encodeArray));</code></p>
<p><code>// Base64 Encode username and password<br />
encode([encodeData length], (char *)[encodeData bytes], sizeof(encodeArray), encodeArray);</code></p>
<p><code>dataStr = [NSString stringWithCString:encodeArray length:strlen(encodeArray)];<br />
myApp.authenticationString = [@"" stringByAppendingFormat:@"Basic %@", dataStr];</code></p>
<p><code>// Create asynchronous request<br />
NSMutableURLRequest * theRequest=(NSMutableURLRequest*)[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.somewebdomain.com"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];<br />
[theRequest addValue:myApp.authenticationString forHTTPHeaderField:@"Authorization"];</code></p>
<p><code>NSURLConnection * theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];</code></p>
<p><code>[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;<br />
if (theConnection) {<br />
receivedData = [[NSMutableData data] retain];<br />
}<br />
else {<br />
[myApp addTextToLog:@"Could not connect to the network" withCaption:@"MyApp"];<br />
}</code></p></blockquote>
<p>Hopefully, this will help people get cracking that were having a hard time getting a handle on the fact that Objective-C is really C &#8211; albeit with funky class extensions.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Mail with Attachments (Unix shellscript)]]></title>
<link>http://mohan43u.wordpress.com/2009/03/06/mail-with-attachments/</link>
<pubDate>Fri, 06 Mar 2009 06:23:44 +0000</pubDate>
<dc:creator>mohan43u</dc:creator>
<guid>http://mohan43u.wordpress.com/2009/03/06/mail-with-attachments/</guid>
<description><![CDATA[Hi friends, Lot of us already know howto send attachments in mails using shellscript. Lot of us alre]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>
Hi friends,</p>
<p>Lot of us already know howto send attachments in mails using shellscript. Lot of us already wrote these kind of script. Here is one more script to do the same thing. I already added all the details in the script itself. It is self explainable. If somebody wants, take it.
</p>
<pre style="background:green;color:yellow;white-space:pre-wrap;">
#!/bin/sh
# generatemail.sh - script to send mail with multiple attachments.
# Wrote By: me! mohan43u.
# Date: Thu Mar 06 11:56:12 IST 2009
# License: Its in public domain. Use it whatever way you can.

USAGE="USAGE:

	generatemail.sh [-t tolist] [-s subject] [-e encodetype]
		[-h] ATTACH_FILE1 ATTACH_FILE2 ...
"
HELP="${USAGE}
OPTIONS:
	-t tolist	comma seperated e-mail addresses
				(Default: current userid).

	-s subject	Subject line (Default: 'test mail from generatemail.sh
				 script')

	-e encodetype	Encoding type (x-uuencode/base64). only GNU uuencode
			can encode in base64. If you are using this script
			in Old school unixes(solaris, HP-UX, AIX, etc) use
			only 'x-uuencode'. Linux can handle both types
			(Default: x-uuencode).

	-h		Print this Help text

This script will read standard input as a mail body and takes filenames as
arguments to generate a preformatted mail content in satndard output. you can
simply pipe the output to any MTA (sendmail, postfix etc.,) to send a mail
with attachments.

Eg:
	$ generatemail.sh -t foo@bar.com -s 'mail with attachments' file1 \
		file2 &#124; /usr/sbin/sendmail -v -i -t
	hi foo,
		I attached file1 and file2 with this mail. Take a look at it.

	Thanks,
	ben.
	[CTRL-D]
	$

	This above command line will attach file1 and file2 and send a mail
	to foo@bar.com. The files file1 and file2 will be encoded in
	'x-uuencode' and attached with this mail.
"

TO="${USER}"
SUBJECT="testmail from generatemail.sh script"
BOUNDARY="`date +'%G%m%d%H%M%S'`"
ENCODE_TYPE="x-uuencode"

while getopts 't:s:e:h' OPTIONS
do
	case "${OPTIONS}" in
	t) TO="${OPTARG}";;
	s) SUBJECT="${OPTARG}";;
	e) ENCODE_TYPE="${OPTARG}";;
	h) echo "${HELP}" &#38;&#38; exit 0;;
	\?) echo "${USAGE}" &#38;&#38; exit 1;;
	esac
done

SHIFT_COUNT=`expr "${OPTIND}" - 1`
shift "${SHIFT_COUNT}"

header()
{
	echo "To: ${TO}"
	echo "Subject: ${SUBJECT}"
	echo "Mime-Version: 1.0"
	echo "Content-Type: multipart/mixed; boundary=\"${BOUNDARY}\""
	echo "Content-Disposition: inline"
	echo "User-Agent: generatemail.sh 0.1"
}
create_octet_part()
{
	BASENAME=`basename "${1}"`
	FILE="${1}"

	if test "${ENCODE_TYPE}" = "base64"
	then
		ENCODED_MESSAGE=`uuencode -m "${FILE}" "${BASENAME}" \
		&#124; egrep -v '^begin&#124;^='`
	else
		ENCODED_MESSAGE=`uuencode "${FILE}" "${BASENAME}"`
	fi

	echo "Content-Type: application/octet-stream"
	echo "Content-Disposition: attachment; filename=\"${BASENAME}\""
	echo "Content-Transfer-Encoding: ${ENCODE_TYPE}"
	echo
	echo "${ENCODED_MESSAGE}"
	echo
}
create_text_part()
{
	echo "Content-type: text/plain; charset=utf-8"
	echo "Content-Disposition: inline"
}

# Main

BODY="`cat`"
header
echo
echo "--${BOUNDARY}"
create_text_part
echo
echo "${BODY}"
echo
for FILENAME
do
	echo "--${BOUNDARY}"
	create_octet_part "${FILENAME}"
done
echo "--${BOUNDARY}--"
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Perl base64 decoder]]></title>
<link>http://rattyboy.wordpress.com/2009/02/25/perl-base64-decoder/</link>
<pubDate>Tue, 24 Feb 2009 13:20:03 +0000</pubDate>
<dc:creator>rattyboy</dc:creator>
<guid>http://rattyboy.wordpress.com/2009/02/25/perl-base64-decoder/</guid>
<description><![CDATA[#!/usr/bin/perl -w use OnSearch::Base64(decode_base64); use strict; use constant DEBUG =&gt; 0; my @]]></description>
<content:encoded><![CDATA[#!/usr/bin/perl -w use OnSearch::Base64(decode_base64); use strict; use constant DEBUG =&gt; 0; my @]]></content:encoded>
</item>
<item>
<title><![CDATA[Python script for Apache RewriteMap]]></title>
<link>http://fragmentsofcode.wordpress.com/2009/02/04/python-script-for-apache-rewritemap/</link>
<pubDate>Wed, 04 Feb 2009 20:00:19 +0000</pubDate>
<dc:creator>David Chandek-Stark</dc:creator>
<guid>http://fragmentsofcode.wordpress.com/2009/02/04/python-script-for-apache-rewritemap/</guid>
<description><![CDATA[It turned out that it didn&#8217;t need this after all, but thought I&#8217;d post it here anyway ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>It turned out that it didn&#8217;t need this after all, but thought I&#8217;d post it here anyway &#8230;</p>
<p>The use case was to base64-encode a URL so that it could be passed as a query parameter to a login page.  The login routes through a third page and returns to the logn page, which redirects the client back to the original URL which was base64-encoded.  Without the encoding, the third page could mangle the original URL.</p>
<p><code>#!/usr/bin/python</p>
<p>import binascii<br />
import sys</p>
<p>while sys.stdin:<br />
    print binascii.b2a_base64(sys.stdin.readline().rstrip()) ,<br />
    sys.stdout.flush()</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Base64 encoding in C programming]]></title>
<link>http://spoofinglife.wordpress.com/2009/01/31/base64-encoding-in-c-programming/</link>
<pubDate>Sat, 31 Jan 2009 01:41:19 +0000</pubDate>
<dc:creator>spoofinglife</dc:creator>
<guid>http://spoofinglife.wordpress.com/2009/01/31/base64-encoding-in-c-programming/</guid>
<description><![CDATA[Just a simple implementation of the base64 encryption algorithm in C. I haven&#8217;t implemented th]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Just a simple implementation of the base64 encryption algorithm in C. I haven&#8217;t implemented the decryption, because I was bored :p , but it&#8217;s easy you could do that by yourself.<br />
Code follows ,</p>
<pre>/*******************************************
        &#124;base64 testcase&#124;
        -----------------
          tes -- &#62; dGVz
*******************************************/

#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#define BITMASK(n) ((1u &#60;&#60; n) - 1)      /* bit mask of n ones ex. 1111, 11111 ... */

/* function prototypes */
void encode( char *buffer, int len);
void Usage(void);

static const char charset[]=
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

int main(int argc, char *argv[]) {

        FILE *input;
        char temp[3];
        int number = 0;
        int c;

        if ( argc != 2) {
                Usage();
                exit(EXIT_FAILURE);
        }

        if ( (input = fopen(argv[1], "r")) == NULL) {
                fprintf(stderr, "Couldn't open file %s\n", argv[1]);
                exit(EXIT_FAILURE);
        }

        printf("\n----------------------------------------------");
        printf("\nThe base64 encrypted text is the following: \n");
	printf("----------------------------------------------\n");

	while( (c = fgetc(input) )!=EOF) {

		temp[number] = c;
		++number;
		if ( number == 3) {
			encode( temp, 3);
			number = 0;
		}
	}
	if (number != 0) {
		if ( number == 1)
			temp[1] = 0;

		temp[2] = 0;
		encode( temp, number);
	}

	fclose(input);
	printf("\n\n\n\n\n");
	printf("****************************************************\n");
	printf("\tThanks for using our base64 algo !!!\n");
	printf("****************************************************\n");
	printf("\n\n");

	exit(EXIT_SUCCESS);
}

void encode( char *buffer, int len) {

	char output[4] = {0,0,0,0};
	int i;

	output[0] = charset[buffer[0] &#62;&#62; 2];
	output[1] = charset[(buffer[0] &#38; BITMASK(2)) &#60;&#60; 4 &#124; (buffer[1] &#62;&#62; 4)];
	output[2] = (len &#62; 1) ? charset[ (buffer[1] &#38; BITMASK(4)) &#60;&#60; 2 &#124; (buffer[2] &#62;&#62; 6)] : '=';
	output[3] = (len &#62; 2) ? charset[  buffer[2] &#38; BITMASK(6)] : '=';					

	for ( i=0; i&#60;4; i++)
		printf("%c", output[i]);
}

void Usage(void) {

	puts("Usage: ./base64 &#60;input_file&#62;");
	puts("Quitting ... \n");
}</pre>
<p>Save it with a .c extension and compile it like:<br />
<em>Command:</em> gcc -Wall -pedantic -std=c99 -o &#60;my_file&#62; &#60;my_file&#62;.c</p>
<p>If no errors occur, run it giving a text file as a parameter:<br />
<em>Command:</em> ./&#60;my_file&#62; &#60;to_be_encrypted_file&#62;</p>
<p>Encode yourelves people :p !!<br />
Comment if you have any questions or fixes!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Browsers support for Base64 encoded data]]></title>
<link>http://perfectionlabstips.wordpress.com/2009/01/23/browsers-support-for-base64-encoded-data/</link>
<pubDate>Fri, 23 Jan 2009 06:18:08 +0000</pubDate>
<dc:creator>Jakub Pawlowicz</dc:creator>
<guid>http://perfectionlabstips.wordpress.com/2009/01/23/browsers-support-for-base64-encoded-data/</guid>
<description><![CDATA[Majority of modern web browsers already support data URIs encoded as Base64 strings. Here is a full ]]></description>
<content:encoded><![CDATA[Majority of modern web browsers already support data URIs encoded as Base64 strings. Here is a full ]]></content:encoded>
</item>
<item>
<title><![CDATA[Terminal Pulsa H2H JPTelecom]]></title>
<link>http://lingga.wordpress.com/2009/01/20/terminal-pulsa-h2h/</link>
<pubDate>Tue, 20 Jan 2009 06:00:29 +0000</pubDate>
<dc:creator>Setia Gunawan</dc:creator>
<guid>http://lingga.wordpress.com/2009/01/20/terminal-pulsa-h2h/</guid>
<description><![CDATA[Terminal Pulsa adalah anak perusahaan Jawa Pos yaitu JP Telecom yang bergerak dibidang distibusi pul]]></description>
<content:encoded><![CDATA[Terminal Pulsa adalah anak perusahaan Jawa Pos yaitu JP Telecom yang bergerak dibidang distibusi pul]]></content:encoded>
</item>
<item>
<title><![CDATA[Zooming in: Base64Decoder]]></title>
<link>http://cryptocode.wordpress.com/2009/01/19/zooming-in-base64decoder/</link>
<pubDate>Mon, 19 Jan 2009 07:34:20 +0000</pubDate>
<dc:creator>CG</dc:creator>
<guid>http://cryptocode.wordpress.com/2009/01/19/zooming-in-base64decoder/</guid>
<description><![CDATA[I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the examples of Crypto++ usage, the plaintext is encoded to a base64 after it&#8217;s being encrypted, and decoded before it&#8217;s being decrypted.</p>
<p>The inheritance diagram for Base64Decoder:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/xflxW98IofvZO5jhFppqow?feat=embedwebsite"><img src="http://lh6.ggpht.com/_qxwqk8abGi8/SXQrDCjpvwI/AAAAAAAAABY/dUHlgUbASnA/s400/Picture%2012.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The encoding process:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/tMR-dF8r5I-sIhjeIheyRg?feat=embedwebsite"><img src="http://lh3.ggpht.com/_qxwqk8abGi8/SXQrDCIqTMI/AAAAAAAAABg/if7a3TGieRw/s400/Picture%2013.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The codes:</p>
<p><span style="color:#ffcc00;">// Encryption<br />
Encryptor.Encrypt( rng, reinterpret_cast( PlainText.c_str() ), PlainTextLength, CipherText );</span></p>
<p><span style="color:#ffcc00;">// Base 64 Encoding<br />
CryptoPP::Base64Encoder Encoder;<br />
Encoder.Put( CipherText, CipherTextLength );<br />
Encoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Encoded Ciphertext<br />
unsigned int EncodedTextLength = Encoder.MaxRetrievable();<br />
byte* EncodedText = new byte[ EncodedTextLength + 1 ]; /* + 1 for NULL termination */<br />
if( NULL == EncodedText ) { throw std::string( &#8220;Base64 EncodedText Allocation Failure&#8221; ); }<br />
::memset( EncodedText, 0xFB, EncodedTextLength );<br />
EncodedText[ EncodedTextLength ] = &#8221;;</p>
<p>// Base 64 Ciphertext<br />
Encoder.Get( EncodedText, EncodedTextLength );</p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Base 64 Encoded Ciphertext (&#8221; &#60;&#60; EncodedTextLength &#60;&#60; &#8221; bytes):&#8221;;<br />
std::cout &#60;&#60; std::endl &#60;&#60; EncodedText &#60;&#60; std::endl;</p>
<p><span style="color:#ffcc00;">// Base 64 Decoding<br />
CryptoPP::Base64Decoder Decoder;<br />
Decoder.Put( EncodedText, EncodedTextLength );<br />
Decoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Decoded Ciphertext<br />
unsigned int DecodedTextLength = Decoder.MaxRetrievable();<br />
byte* DecodedText = new byte[ DecodedTextLength ];<br />
if( NULL == DecodedText ) { throw std::string( &#8220;Base64 DecodedText Allocation Failure&#8221; ); }<br />
::memset( DecodedText, 0xFB, DecodedTextLength );</p>
<p>// Ciphertext is no longer Encoded<br />
Decoder.Get( DecodedText, DecodedTextLength );</p>
<p>//<br />
// At this point, RecoveredText64 = CipherText<br />
//<br />
assert( DecodedTextLength == CipherTextLength );<br />
assert( 0 == ::memcmp( DecodedText, CipherText, CipherTextLength ) );</p>
<p>// Scratch for Decryption<br />
unsigned int RecoveredTextLength = Decryptor.MaxPlaintextLength( CipherTextLength );<br />
if( 0 == RecoveredTextLength ) { throw std::string(&#8220;ciphertextLength is not valid (too long or too short)&#8221;); }</p>
<p>// Decryption Buffer<br />
char* RecoveredText = new char[ RecoveredTextLength ];<br />
if( NULL == RecoveredText ) { throw std::string( &#8220;RecoveredText CipherText Allocation Failure&#8221; ); }<br />
::memset( RecoveredText, 0xFB, RecoveredTextLength );</p>
<p><span style="color:#ffcc00;">// Decryption<br />
Decryptor.Decrypt( rng, CipherText, CipherTextLength, reinterpret_cast( RecoveredText ) );</span></p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Recovered text (&#8221; &#60;&#60; RecoveredTextLength &#60;&#60; &#8221; bytes):&#8221; &#60;&#60; std::endl;<br />
std::cout &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; RecoveredText &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; std::endl;</p>
<p><strong>Questions:</strong></p>
<ol>
<li>Why should the plaintext be encoded to base64?</li>
<li>Why the plaintext is encoded after it&#8217;s encrypted not the vice versa?</li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Zooming in: Base64Decoder]]></title>
<link>http://cryptocodecg.wordpress.com/2009/01/19/zooming-in-base64decoder/</link>
<pubDate>Mon, 19 Jan 2009 07:34:20 +0000</pubDate>
<dc:creator>CG</dc:creator>
<guid>http://cryptocodecg.wordpress.com/2009/01/19/zooming-in-base64decoder/</guid>
<description><![CDATA[I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the examples of Crypto++ usage, the plaintext is encoded to a base64 after it&#8217;s being encrypted, and decoded before it&#8217;s being decrypted.</p>
<p>The inheritance diagram for Base64Decoder:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/xflxW98IofvZO5jhFppqow?feat=embedwebsite"><img src="http://lh6.ggpht.com/_qxwqk8abGi8/SXQrDCjpvwI/AAAAAAAAABY/dUHlgUbASnA/s400/Picture%2012.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The encoding process:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/tMR-dF8r5I-sIhjeIheyRg?feat=embedwebsite"><img src="http://lh3.ggpht.com/_qxwqk8abGi8/SXQrDCIqTMI/AAAAAAAAABg/if7a3TGieRw/s400/Picture%2013.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The codes:</p>
<p><span style="color:#ffcc00;">// Encryption<br />
Encryptor.Encrypt( rng, reinterpret_cast( PlainText.c_str() ), PlainTextLength, CipherText );</span></p>
<p><span style="color:#ffcc00;">// Base 64 Encoding<br />
CryptoPP::Base64Encoder Encoder;<br />
Encoder.Put( CipherText, CipherTextLength );<br />
Encoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Encoded Ciphertext<br />
unsigned int EncodedTextLength = Encoder.MaxRetrievable();<br />
byte* EncodedText = new byte[ EncodedTextLength + 1 ]; /* + 1 for NULL termination */<br />
if( NULL == EncodedText ) { throw std::string( &#8220;Base64 EncodedText Allocation Failure&#8221; ); }<br />
::memset( EncodedText, 0xFB, EncodedTextLength );<br />
EncodedText[ EncodedTextLength ] = &#8221;;</p>
<p>// Base 64 Ciphertext<br />
Encoder.Get( EncodedText, EncodedTextLength );</p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Base 64 Encoded Ciphertext (&#8221; &#60;&#60; EncodedTextLength &#60;&#60; &#8221; bytes):&#8221;;<br />
std::cout &#60;&#60; std::endl &#60;&#60; EncodedText &#60;&#60; std::endl;</p>
<p><span style="color:#ffcc00;">// Base 64 Decoding<br />
CryptoPP::Base64Decoder Decoder;<br />
Decoder.Put( EncodedText, EncodedTextLength );<br />
Decoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Decoded Ciphertext<br />
unsigned int DecodedTextLength = Decoder.MaxRetrievable();<br />
byte* DecodedText = new byte[ DecodedTextLength ];<br />
if( NULL == DecodedText ) { throw std::string( &#8220;Base64 DecodedText Allocation Failure&#8221; ); }<br />
::memset( DecodedText, 0xFB, DecodedTextLength );</p>
<p>// Ciphertext is no longer Encoded<br />
Decoder.Get( DecodedText, DecodedTextLength );</p>
<p>//<br />
// At this point, RecoveredText64 = CipherText<br />
//<br />
assert( DecodedTextLength == CipherTextLength );<br />
assert( 0 == ::memcmp( DecodedText, CipherText, CipherTextLength ) );</p>
<p>// Scratch for Decryption<br />
unsigned int RecoveredTextLength = Decryptor.MaxPlaintextLength( CipherTextLength );<br />
if( 0 == RecoveredTextLength ) { throw std::string(&#8220;ciphertextLength is not valid (too long or too short)&#8221;); }</p>
<p>// Decryption Buffer<br />
char* RecoveredText = new char[ RecoveredTextLength ];<br />
if( NULL == RecoveredText ) { throw std::string( &#8220;RecoveredText CipherText Allocation Failure&#8221; ); }<br />
::memset( RecoveredText, 0xFB, RecoveredTextLength );</p>
<p><span style="color:#ffcc00;">// Decryption<br />
Decryptor.Decrypt( rng, CipherText, CipherTextLength, reinterpret_cast( RecoveredText ) );</span></p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Recovered text (&#8221; &#60;&#60; RecoveredTextLength &#60;&#60; &#8221; bytes):&#8221; &#60;&#60; std::endl;<br />
std::cout &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; RecoveredText &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; std::endl;</p>
<p><strong>Questions:</strong></p>
<ol>
<li>Why should the plaintext be encoded to base64?</li>
<li>Why the plaintext is encoded after it&#8217;s encrypted not the vice versa?</li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Zooming in: Base64Decoder]]></title>
<link>http://cgthecodegirl.wordpress.com/2009/01/19/zooming-in-base64decoder/</link>
<pubDate>Mon, 19 Jan 2009 07:34:20 +0000</pubDate>
<dc:creator>CG</dc:creator>
<guid>http://cgthecodegirl.wordpress.com/2009/01/19/zooming-in-base64decoder/</guid>
<description><![CDATA[I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the examples of Crypto++ usage, the plaintext is encoded to a base64 after it&#8217;s being encrypted, and decoded before it&#8217;s being decrypted.</p>
<p>The inheritance diagram for Base64Decoder:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/xflxW98IofvZO5jhFppqow?feat=embedwebsite"><img src="http://lh6.ggpht.com/_qxwqk8abGi8/SXQrDCjpvwI/AAAAAAAAABY/dUHlgUbASnA/s400/Picture%2012.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The encoding process:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/tMR-dF8r5I-sIhjeIheyRg?feat=embedwebsite"><img src="http://lh3.ggpht.com/_qxwqk8abGi8/SXQrDCIqTMI/AAAAAAAAABg/if7a3TGieRw/s400/Picture%2013.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The codes:</p>
<p><span style="color:#ffcc00;">// Encryption<br />
Encryptor.Encrypt( rng, reinterpret_cast( PlainText.c_str() ), PlainTextLength, CipherText );</span></p>
<p><span style="color:#ffcc00;">// Base 64 Encoding<br />
CryptoPP::Base64Encoder Encoder;<br />
Encoder.Put( CipherText, CipherTextLength );<br />
Encoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Encoded Ciphertext<br />
unsigned int EncodedTextLength = Encoder.MaxRetrievable();<br />
byte* EncodedText = new byte[ EncodedTextLength + 1 ]; /* + 1 for NULL termination */<br />
if( NULL == EncodedText ) { throw std::string( &#8220;Base64 EncodedText Allocation Failure&#8221; ); }<br />
::memset( EncodedText, 0xFB, EncodedTextLength );<br />
EncodedText[ EncodedTextLength ] = &#8221;;</p>
<p>// Base 64 Ciphertext<br />
Encoder.Get( EncodedText, EncodedTextLength );</p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Base 64 Encoded Ciphertext (&#8221; &#60;&#60; EncodedTextLength &#60;&#60; &#8221; bytes):&#8221;;<br />
std::cout &#60;&#60; std::endl &#60;&#60; EncodedText &#60;&#60; std::endl;</p>
<p><span style="color:#ffcc00;">// Base 64 Decoding<br />
CryptoPP::Base64Decoder Decoder;<br />
Decoder.Put( EncodedText, EncodedTextLength );<br />
Decoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Decoded Ciphertext<br />
unsigned int DecodedTextLength = Decoder.MaxRetrievable();<br />
byte* DecodedText = new byte[ DecodedTextLength ];<br />
if( NULL == DecodedText ) { throw std::string( &#8220;Base64 DecodedText Allocation Failure&#8221; ); }<br />
::memset( DecodedText, 0xFB, DecodedTextLength );</p>
<p>// Ciphertext is no longer Encoded<br />
Decoder.Get( DecodedText, DecodedTextLength );</p>
<p>//<br />
// At this point, RecoveredText64 = CipherText<br />
//<br />
assert( DecodedTextLength == CipherTextLength );<br />
assert( 0 == ::memcmp( DecodedText, CipherText, CipherTextLength ) );</p>
<p>// Scratch for Decryption<br />
unsigned int RecoveredTextLength = Decryptor.MaxPlaintextLength( CipherTextLength );<br />
if( 0 == RecoveredTextLength ) { throw std::string(&#8220;ciphertextLength is not valid (too long or too short)&#8221;); }</p>
<p>// Decryption Buffer<br />
char* RecoveredText = new char[ RecoveredTextLength ];<br />
if( NULL == RecoveredText ) { throw std::string( &#8220;RecoveredText CipherText Allocation Failure&#8221; ); }<br />
::memset( RecoveredText, 0xFB, RecoveredTextLength );</p>
<p><span style="color:#ffcc00;">// Decryption<br />
Decryptor.Decrypt( rng, CipherText, CipherTextLength, reinterpret_cast( RecoveredText ) );</span></p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Recovered text (&#8221; &#60;&#60; RecoveredTextLength &#60;&#60; &#8221; bytes):&#8221; &#60;&#60; std::endl;<br />
std::cout &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; RecoveredText &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; std::endl;</p>
<p><strong>Questions:</strong></p>
<ol>
<li>Why should the plaintext be encoded to base64?</li>
<li>Why the plaintext is encoded after it&#8217;s encrypted not the vice versa?</li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Zooming in: Base64Decoder]]></title>
<link>http://chikaradirghsa.wordpress.com/2009/01/19/zooming-in-base64decoder/</link>
<pubDate>Mon, 19 Jan 2009 07:34:20 +0000</pubDate>
<dc:creator>CG</dc:creator>
<guid>http://chikaradirghsa.wordpress.com/2009/01/19/zooming-in-base64decoder/</guid>
<description><![CDATA[I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m zooming in the process of converting plaintext to a point in elliptic curve. And from the examples of Crypto++ usage, the plaintext is encoded to a base64 after it&#8217;s being encrypted, and decoded before it&#8217;s being decrypted.</p>
<p>The inheritance diagram for Base64Decoder:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/xflxW98IofvZO5jhFppqow?feat=embedwebsite"><img src="http://lh6.ggpht.com/_qxwqk8abGi8/SXQrDCjpvwI/AAAAAAAAABY/dUHlgUbASnA/s400/Picture%2012.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The encoding process:</p>
<table style="width:auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/tMR-dF8r5I-sIhjeIheyRg?feat=embedwebsite"><img src="http://lh3.ggpht.com/_qxwqk8abGi8/SXQrDCIqTMI/AAAAAAAAABg/if7a3TGieRw/s400/Picture%2013.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family:arial,sans-serif;font-size:11px;text-align:right;">From <a href="http://picasaweb.google.com/chikaradirghsa/Research?feat=embedwebsite">Research</a></td>
</tr>
</tbody>
</table>
<p>The codes:</p>
<p><span style="color:#ffcc00;">// Encryption<br />
Encryptor.Encrypt( rng, reinterpret_cast( PlainText.c_str() ), PlainTextLength, CipherText );</span></p>
<p><span style="color:#ffcc00;">// Base 64 Encoding<br />
CryptoPP::Base64Encoder Encoder;<br />
Encoder.Put( CipherText, CipherTextLength );<br />
Encoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Encoded Ciphertext<br />
unsigned int EncodedTextLength = Encoder.MaxRetrievable();<br />
byte* EncodedText = new byte[ EncodedTextLength + 1 ]; /* + 1 for NULL termination */<br />
if( NULL == EncodedText ) { throw std::string( &#8220;Base64 EncodedText Allocation Failure&#8221; ); }<br />
::memset( EncodedText, 0xFB, EncodedTextLength );<br />
EncodedText[ EncodedTextLength ] = &#8221;;</p>
<p>// Base 64 Ciphertext<br />
Encoder.Get( EncodedText, EncodedTextLength );</p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Base 64 Encoded Ciphertext (&#8221; &#60;&#60; EncodedTextLength &#60;&#60; &#8221; bytes):&#8221;;<br />
std::cout &#60;&#60; std::endl &#60;&#60; EncodedText &#60;&#60; std::endl;</p>
<p><span style="color:#ffcc00;">// Base 64 Decoding<br />
CryptoPP::Base64Decoder Decoder;<br />
Decoder.Put( EncodedText, EncodedTextLength );<br />
Decoder.MessageEnd();</span></p>
<p>// Scratch for Base 64 Decoded Ciphertext<br />
unsigned int DecodedTextLength = Decoder.MaxRetrievable();<br />
byte* DecodedText = new byte[ DecodedTextLength ];<br />
if( NULL == DecodedText ) { throw std::string( &#8220;Base64 DecodedText Allocation Failure&#8221; ); }<br />
::memset( DecodedText, 0xFB, DecodedTextLength );</p>
<p>// Ciphertext is no longer Encoded<br />
Decoder.Get( DecodedText, DecodedTextLength );</p>
<p>//<br />
// At this point, RecoveredText64 = CipherText<br />
//<br />
assert( DecodedTextLength == CipherTextLength );<br />
assert( 0 == ::memcmp( DecodedText, CipherText, CipherTextLength ) );</p>
<p>// Scratch for Decryption<br />
unsigned int RecoveredTextLength = Decryptor.MaxPlaintextLength( CipherTextLength );<br />
if( 0 == RecoveredTextLength ) { throw std::string(&#8220;ciphertextLength is not valid (too long or too short)&#8221;); }</p>
<p>// Decryption Buffer<br />
char* RecoveredText = new char[ RecoveredTextLength ];<br />
if( NULL == RecoveredText ) { throw std::string( &#8220;RecoveredText CipherText Allocation Failure&#8221; ); }<br />
::memset( RecoveredText, 0xFB, RecoveredTextLength );</p>
<p><span style="color:#ffcc00;">// Decryption<br />
Decryptor.Decrypt( rng, CipherText, CipherTextLength, reinterpret_cast( RecoveredText ) );</span></p>
<p>// Diagnostics<br />
std::cout &#60;&#60; &#8220;Recovered text (&#8221; &#60;&#60; RecoveredTextLength &#60;&#60; &#8221; bytes):&#8221; &#60;&#60; std::endl;<br />
std::cout &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; RecoveredText &#60;&#60; &#8220;&#8216;&#8221; &#60;&#60; std::endl;</p>
<p><strong>Questions:</strong></p>
<ol>
<li>Why should the plaintext be encoded to base64?</li>
<li>Why the plaintext is encoded after it&#8217;s encrypted not the vice versa?</li>
</ol>
</div>]]></content:encoded>
</item>

</channel>
</rss>
