<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Ron&#8217;s Cipher #4</title>
	<atom:link href="http://programmingpraxis.com/2009/09/04/rons-cipher-4/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/09/04/rons-cipher-4/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Mon, 28 May 2012 03:30:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: VaporWarning&#187; Blog Archive &#187; Learning Python by example: RC4</title>
		<link>http://programmingpraxis.com/2009/09/04/rons-cipher-4/#comment-640</link>
		<dc:creator><![CDATA[VaporWarning&#187; Blog Archive &#187; Learning Python by example: RC4]]></dc:creator>
		<pubDate>Mon, 21 Sep 2009 05:54:33 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1238#comment-640</guid>
		<description><![CDATA[[...] in point, I&#8217;ll use the recent kata from Programming Praxis for this Python exercise, as they provide straightforward pseudocode. Here&#8217;s the encryption [...]]]></description>
		<content:encoded><![CDATA[<p>[...] in point, I&#8217;ll use the recent kata from Programming Praxis for this Python exercise, as they provide straightforward pseudocode. Here&#8217;s the encryption [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Posts about Programming from google blogs as of September 4, 2009 &#171; tryfly.com</title>
		<link>http://programmingpraxis.com/2009/09/04/rons-cipher-4/#comment-597</link>
		<dc:creator><![CDATA[Posts about Programming from google blogs as of September 4, 2009 &#171; tryfly.com]]></dc:creator>
		<pubDate>Sat, 05 Sep 2009 00:02:22 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1238#comment-597</guid>
		<description><![CDATA[[...]  [...]]]></description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2009/09/04/rons-cipher-4/#comment-595</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Fri, 04 Sep 2009 19:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1238#comment-595</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2009/09/04/programming-praxis-ron%E2%80%99s-cipher-4/ for a version with comments):

[sourcecode lang=&#039;css&#039;]
import Data.Bits
import Data.Char
import Data.IntMap ((!), fromList, insert, size, IntMap)

swap :: Int -&gt; Int -&gt; IntMap a -&gt; IntMap a
swap i j a = insert j (a ! i) $ insert i (a ! j) a

rc4init :: IntMap Char -&gt; IntMap Int
rc4init key = snd $ foldl (\(j, a) i -&gt;
    let j&#039; = mod (j + a ! i + ord (key ! mod i (size key))) 256
    in (j&#039;, swap i j&#039; a)) (0, s) [0..255] where
    s = fromList $ zip [0..] [0..255]
  
rc4 :: String -&gt; String -&gt; String
rc4 key = map chr . zipWith xor (stream key) . map ord where
    stream = s 0 0 . rc4init . fromList . zip [0..]
    s i&#039; j&#039; k&#039; = k ! (mod (k ! i + k ! j) 256) : s i j k where
                 i = mod (i&#039; + 1) 256
                 j = mod (j&#039; + k&#039; ! i) 256
                 k = swap i j k&#039;
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2009/09/04/programming-praxis-ron%E2%80%99s-cipher-4/" rel="nofollow">http://bonsaicode.wordpress.com/2009/09/04/programming-praxis-ron%E2%80%99s-cipher-4/</a> for a version with comments):</p>
<pre class="brush: css;">
import Data.Bits
import Data.Char
import Data.IntMap ((!), fromList, insert, size, IntMap)

swap :: Int -&gt; Int -&gt; IntMap a -&gt; IntMap a
swap i j a = insert j (a ! i) $ insert i (a ! j) a

rc4init :: IntMap Char -&gt; IntMap Int
rc4init key = snd $ foldl (\(j, a) i -&gt;
    let j' = mod (j + a ! i + ord (key ! mod i (size key))) 256
    in (j', swap i j' a)) (0, s) [0..255] where
    s = fromList $ zip [0..] [0..255]
  
rc4 :: String -&gt; String -&gt; String
rc4 key = map chr . zipWith xor (stream key) . map ord where
    stream = s 0 0 . rc4init . fromList . zip [0..]
    s i' j' k' = k ! (mod (k ! i + k ! j) 256) : s i j k where
                 i = mod (i' + 1) 256
                 j = mod (j' + k' ! i) 256
                 k = swap i j k'
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Ron’s Cipher #4 &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2009/09/04/rons-cipher-4/#comment-594</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Ron’s Cipher #4 &#171; Bonsai Code]]></dc:creator>
		<pubDate>Fri, 04 Sep 2009 19:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1238#comment-594</guid>
		<description><![CDATA[[...] Praxis &#8211; Ron’s Cipher&#160;#4 By Remco Niemeijer  In today’s Programming Praxis problem, we have to implement the RC4 cipher, which is often used in protocols [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211; Ron’s Cipher&nbsp;#4 By Remco Niemeijer  In today’s Programming Praxis problem, we have to implement the RC4 cipher, which is often used in protocols [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

