<?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"
	>
<channel>
	<title>Comments for Evan Fosmark</title>
	<atom:link href="http://www.evanfosmark.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.evanfosmark.com</link>
	<description>This is my world of code. Take a look around and enjoy yourself.</description>
	<pubDate>Tue, 06 Jan 2009 21:26:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>Comment on Python WSGI Middleware for automatic Gzipping by Sergey</title>
		<link>http://www.evanfosmark.com/2008/12/python-wsgi-middleware-for-automatic-gzipping/#comment-76</link>
		<dc:creator>Sergey</dc:creator>
		<pubDate>Sun, 28 Dec 2008 00:14:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=43#comment-76</guid>
		<description>In the first for loop, you could do

encoding, sep, qvalue = encoding.partition(';')
qvalue = qvalue.partition('=')[2]
qvalue = 1 if not qvalue else float(qvalue)
encodings[encoding] = qvalue

The advantage here is that the code is linear. The disadvantage is that a later Python version is required.</description>
		<content:encoded><![CDATA[<p>In the first for loop, you could do</p>
<p>encoding, sep, qvalue = encoding.partition(&#039;;')<br />
qvalue = qvalue.partition(&#039;=')[2]<br />
qvalue = 1 if not qvalue else float(qvalue)<br />
encodings[encoding] = qvalue</p>
<p>The advantage here is that the code is linear. The disadvantage is that a later Python version is required.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Python WSGI Middleware for automatic Gzipping by Evan</title>
		<link>http://www.evanfosmark.com/2008/12/python-wsgi-middleware-for-automatic-gzipping/#comment-75</link>
		<dc:creator>Evan</dc:creator>
		<pubDate>Fri, 26 Dec 2008 08:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=43#comment-75</guid>
		<description>Jim, thank you for your input. I have updated the code accordingly.</description>
		<content:encoded><![CDATA[<p>Jim, thank you for your input. I have updated the code accordingly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Python WSGI Middleware for automatic Gzipping by Jim</title>
		<link>http://www.evanfosmark.com/2008/12/python-wsgi-middleware-for-automatic-gzipping/#comment-74</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Fri, 26 Dec 2008 01:18:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=43#comment-74</guid>
		<description>Two bugs:

&#62; if(environ.get("HTTP_ACCEPT_ENCODING", "").find("gzip") &#60; 0)

This fails for cases like Accept-Encoding: identity, compress;q=0.5, gzip;q=0

You need to actually split up the header value properly in order to handle it correctly, a simple search fails for corner cases.

You also need to transmit a Vary header.</description>
		<content:encoded><![CDATA[<p>Two bugs:</p>
<p>&gt; if(environ.get(&#034;HTTP_ACCEPT_ENCODING&#034;, &#034;&#034;).find(&#034;gzip&#034;) &lt; 0)</p>
<p>This fails for cases like Accept-Encoding: identity, compress;q=0.5, gzip;q=0</p>
<p>You need to actually split up the header value properly in order to handle it correctly, a simple search fails for corner cases.</p>
<p>You also need to transmit a Vary header.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Python WSGI Middleware for automatic Gzipping by Evan</title>
		<link>http://www.evanfosmark.com/2008/12/python-wsgi-middleware-for-automatic-gzipping/#comment-73</link>
		<dc:creator>Evan</dc:creator>
		<pubDate>Thu, 25 Dec 2008 23:45:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=43#comment-73</guid>
		<description>Heh, yeah I guess you're right. It just looks messy to me. :-P</description>
		<content:encoded><![CDATA[<p>Heh, yeah I guess you&#039;re right. It just looks messy to me. :-P</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Python WSGI Middleware for automatic Gzipping by japherwocky</title>
		<link>http://www.evanfosmark.com/2008/12/python-wsgi-middleware-for-automatic-gzipping/#comment-72</link>
		<dc:creator>japherwocky</dc:creator>
		<pubDate>Thu, 25 Dec 2008 22:28:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=43#comment-72</guid>
		<description>I think that's exactly the proper usage of StringIO.  Not a hack at all. :)</description>
		<content:encoded><![CDATA[<p>I think that&#039;s exactly the proper usage of StringIO.  Not a hack at all. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on XOR Encryption With Python by Dan</title>
		<link>http://www.evanfosmark.com/2008/06/xor-encryption-with-python/#comment-71</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Wed, 24 Dec 2008 20:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=14#comment-71</guid>
		<description>The one-time pad is the only cipher known to be 100% secure, because there is no way to determine that any given key is correct. The problem with trying to cryptanalyze (break) such a cipher as this is that you can never be sure that you actually have the correct key. Like you said, though, this cipher requires a key with the same length as the plaintext (unencrypted text) that is never reused and has perfect randomness. The funny thing about randomness is this: There's no good test for it!

Consider this sequence of numbers: 1, 1, 1, 1, 1, 1

That sequence looks very non-random, but it's impossible to tell if that was generated by repeating the number 1, by picking numbers randomly from a hat or from one's mind, by choosing from a limited set of numbers using a poor random number generator, by choosing from an infinite set of numbers using a perfect random number generator...

And of course, how do you transmit the keys safely? ;)</description>
		<content:encoded><![CDATA[<p>The one-time pad is the only cipher known to be 100% secure, because there is no way to determine that any given key is correct. The problem with trying to cryptanalyze (break) such a cipher as this is that you can never be sure that you actually have the correct key. Like you said, though, this cipher requires a key with the same length as the plaintext (unencrypted text) that is never reused and has perfect randomness. The funny thing about randomness is this: There&#039;s no good test for it!</p>
<p>Consider this sequence of numbers: 1, 1, 1, 1, 1, 1</p>
<p>That sequence looks very non-random, but it&#039;s impossible to tell if that was generated by repeating the number 1, by picking numbers randomly from a hat or from one&#039;s mind, by choosing from a limited set of numbers using a poor random number generator, by choosing from an infinite set of numbers using a perfect random number generator&#8230;</p>
<p>And of course, how do you transmit the keys safely? ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on XOR Encryption With Python by Jordan</title>
		<link>http://www.evanfosmark.com/2008/06/xor-encryption-with-python/#comment-69</link>
		<dc:creator>Jordan</dc:creator>
		<pubDate>Sun, 07 Dec 2008 03:08:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=14#comment-69</guid>
		<description>Here is a function written in python using xor encryption.  The file target is a file path (i.e., /root/myfile.txt) and the key can be one of two things: a simple text password ("mypassword") or a path to a file to be used as a key("/root/myKey.key").  I do not have izip, so I commented out the list comprehension you gave on this site.

&lt;pre lang="python"&gt;
def xor(fileTarget, key):
	fileTarget = fileTarget + os.listdir(fileTarget)[0]
	
	ifile = os.path.split(fileTarget)[0]+"/xor.in"
	ofile = os.path.split(fileTarget)[0]+"/xor.out"
	os.rename(fileTarget, ifile)
	
	if os.path.isfile(key):
		kf = open(key)
		keyData = kf.read()
		kf.close()
	else:
		keyData = key
		
	e = open(ofile, "w")
	f = open(ifile, "r")
	
	bytesToCopy = os.stat(os.path.split(fileTarget)[0]+"/xor.in")[6]
	
	while bytesToCopy:
		
		if bytesToCopy &#62;= len(keyData):
			data = f.read(len(keyData))
			bytesToCopy -= len(keyData)
			encryptedData = ''.join([chr(ord(data[i])^ord(keyData[i])) for i in xrange(len(data))])
			# encryptedData = ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
			e.write(encryptedData)
			
		else:
			data = f.read(bytesToCopy)
			bytesToCopy = 0
			encryptedData = ''.join([chr(ord(data[i])^ord(keyData[i])) for i in xrange(len(data))])
			# encryptedData = ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
			e.write(encryptedData)
	os.remove(ifile)
	
	e.close()
	f.close()
	
	return os.path.split(fileTarget)[0]+"/xor.out"
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Here is a function written in python using xor encryption.  The file target is a file path (i.e., /root/myfile.txt) and the key can be one of two things: a simple text password (&#034;mypassword&#034;) or a path to a file to be used as a key(&#034;/root/myKey.key&#034;).  I do not have izip, so I commented out the list comprehension you gave on this site.</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">def</span> xor<span style="color: black;">&#40;</span>fileTarget, key<span style="color: black;">&#41;</span>:
	fileTarget = fileTarget + <span style="color: #dc143c;">os</span>.<span style="color: black;">listdir</span><span style="color: black;">&#40;</span>fileTarget<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
	ifile = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span>fileTarget<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;/xor.in&quot;</span>
	ofile = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span>fileTarget<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;/xor.out&quot;</span>
	<span style="color: #dc143c;">os</span>.<span style="color: black;">rename</span><span style="color: black;">&#40;</span>fileTarget, ifile<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">isfile</span><span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span>:
		kf = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span>
		keyData = kf.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		kf.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">else</span>:
		keyData = key
&nbsp;
	e = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>ofile, <span style="color: #483d8b;">&quot;w&quot;</span><span style="color: black;">&#41;</span>
	f = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>ifile, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
	bytesToCopy = <span style="color: #dc143c;">os</span>.<span style="color: #dc143c;">stat</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span>fileTarget<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;/xor.in&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">while</span> bytesToCopy:
&nbsp;
		<span style="color: #ff7700;font-weight:bold;">if</span> bytesToCopy <span style="color: #66cc66;">&amp;</span>gt<span style="color: #66cc66;">;</span>= <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>keyData<span style="color: black;">&#41;</span>:
			data = f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>keyData<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
			bytesToCopy -= <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>keyData<span style="color: black;">&#41;</span>
			encryptedData = <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">chr</span><span style="color: black;">&#40;</span><span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>^ord<span style="color: black;">&#40;</span>keyData<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
			<span style="color: #808080; font-style: italic;"># encryptedData = ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))</span>
			e.<span style="color: black;">write</span><span style="color: black;">&#40;</span>encryptedData<span style="color: black;">&#41;</span>
&nbsp;
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			data = f.<span style="color: black;">read</span><span style="color: black;">&#40;</span>bytesToCopy<span style="color: black;">&#41;</span>
			bytesToCopy = <span style="color: #ff4500;">0</span>
			encryptedData = <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">chr</span><span style="color: black;">&#40;</span><span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>^ord<span style="color: black;">&#40;</span>keyData<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
			<span style="color: #808080; font-style: italic;"># encryptedData = ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))</span>
			e.<span style="color: black;">write</span><span style="color: black;">&#40;</span>encryptedData<span style="color: black;">&#41;</span>
	<span style="color: #dc143c;">os</span>.<span style="color: black;">remove</span><span style="color: black;">&#40;</span>ifile<span style="color: black;">&#41;</span>
&nbsp;
	e.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	f.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span>fileTarget<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;/xor.out&quot;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>Comment on About by Bacon Should Not Be Worshiped&#160;&#124;&#160;Bacon Today</title>
		<link>http://www.evanfosmark.com/about/#comment-66</link>
		<dc:creator>Bacon Should Not Be Worshiped&#160;&#124;&#160;Bacon Today</dc:creator>
		<pubDate>Sat, 22 Nov 2008 08:04:08 +0000</pubDate>
		<guid isPermaLink="false">http://evanfosmark.com/?page_id=2#comment-66</guid>
		<description>[...] via: Evan Fosmark [...]</description>
		<content:encoded><![CDATA[<p>[...] via: Evan Fosmark [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Ternary Operator in Python - People got Clever by Alysse</title>
		<link>http://www.evanfosmark.com/2008/06/ternary-operator-in-python-people-got-clever/#comment-62</link>
		<dc:creator>Alysse</dc:creator>
		<pubDate>Thu, 23 Oct 2008 23:50:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=15#comment-62</guid>
		<description>I LOVE YOU, EVIE!!</description>
		<content:encoded><![CDATA[<p>I LOVE YOU, EVIE!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on I Before E, Except After C - Not a rule, but a joke by Alysse</title>
		<link>http://www.evanfosmark.com/2008/07/i-before-e-except-after-c-not-a-rule/#comment-13</link>
		<dc:creator>Alysse</dc:creator>
		<pubDate>Fri, 18 Jul 2008 05:31:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.evanfosmark.com/?p=27#comment-13</guid>
		<description>This is brilliant! I love it!</description>
		<content:encoded><![CDATA[<p>This is brilliant! I love it!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
