<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: base64 code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 14:09:31 GMT</pubDate>
    <description>DZone Snippets: base64 code</description>
    <item>
      <title>Simple base64 encoder/decoder in command-line with D</title>
      <link>http://snippets.dzone.com/posts/show/5780</link>
      <description>&lt;code&gt;&lt;br /&gt;import std.base64;&lt;br /&gt;import std.stdio;&lt;br /&gt;import std.array;&lt;br /&gt;void main(string[] args)&lt;br /&gt; {&lt;br /&gt;	try {&lt;br /&gt;		string action = args[1];&lt;br /&gt;		string source = args[2];&lt;br /&gt;		string dest;&lt;br /&gt;		if(action == "encode") {&lt;br /&gt;			dest = std.base64.encode(source);&lt;br /&gt;		}&lt;br /&gt;		else if(action == "decode") {&lt;br /&gt;			dest = std.base64.decode(source);&lt;br /&gt;		}&lt;br /&gt;		else {&lt;br /&gt;			writeln("Error: Bad Action");&lt;br /&gt;			return 1;&lt;br /&gt;		}&lt;br /&gt;		writeln(dest);&lt;br /&gt;		return 0;&lt;br /&gt;	}&lt;br /&gt;	catch(ArrayBoundsError err) {&lt;br /&gt;		writefln("Error: Missing argument (%s action string)", args[0]);&lt;br /&gt;	}&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Usage: b64utils [de/en]code mytext</description>
      <pubDate>Thu, 17 Jul 2008 19:16:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5780</guid>
      <author>kedare (Mathieu Poussin)</author>
    </item>
    <item>
      <title>base64</title>
      <link>http://snippets.dzone.com/posts/show/4072</link>
      <description>Simple python script to trnasform std input to base64 encoding&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#! /usr/bin/python&lt;br /&gt;&lt;br /&gt;import base64&lt;br /&gt;import sys&lt;br /&gt;&lt;br /&gt;encoded = base64.b64encode(sys.stdin.read())&lt;br /&gt;&lt;br /&gt;print encoded&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 30 May 2007 10:31:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4072</guid>
      <author>cdvddt (Raphael Jolivet)</author>
    </item>
    <item>
      <title>Using base64 to encode/decode data</title>
      <link>http://snippets.dzone.com/posts/show/1618</link>
      <description>If you have binary data, you can encode it with&lt;br /&gt;ascii character to store it more safely.&lt;br /&gt;base64 module is an efficient choice to do so.&lt;br /&gt;It uses characters from this set&lt;br /&gt;('=' is used for padding at the end.)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ&lt;br /&gt;abcdefghijklmnopqrstuvwxyz&lt;br /&gt;0123456789+/&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Here's how to use it.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; import base64&lt;br /&gt;&gt;&gt;&gt; base64.encodestring('hello world')&lt;br /&gt;'aGVsbG8gd29ybGQ=\n'&lt;br /&gt;&gt;&gt;&gt; base64.decodestring(_)&lt;br /&gt;'hello world'&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;If the text is long, the base64 module will split&lt;br /&gt;the encoded data into multiple lines.&lt;br /&gt;If you don't wan't it to be split. You can use&lt;br /&gt;binascii.b2a_base64 instead of base64.encodestring and&lt;br /&gt;binascii.a2b_base64 instead of base64.decodestring&lt;br /&gt;</description>
      <pubDate>Thu, 02 Mar 2006 19:28:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1618</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
