<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>the cosmotron &#187; Programming</title>
	<atom:link href="http://thecosmotron.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecosmotron.com</link>
	<description>the blog of ryan lewis</description>
	<lastBuildDate>Wed, 17 Feb 2010 06:23:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zero-Knowledge and You: A Beginner&#8217;s Guide to SPHiNX &amp; Challenge-Response Protocols</title>
		<link>http://thecosmotron.com/2009/01/29/zero-knowledge-and-you-a-beginners-guide-to-sphinx-challenge-response-protocols/</link>
		<comments>http://thecosmotron.com/2009/01/29/zero-knowledge-and-you-a-beginners-guide-to-sphinx-challenge-response-protocols/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 00:27:03 +0000</pubDate>
		<dc:creator>Ryan Lewis</dc:creator>
				<category><![CDATA[Planet COSI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[paper]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://thecosmotron.com/?p=87</guid>
		<description><![CDATA[This is a paper that Josh Hollenbeck, Pat Wilbur, and myself wrote last semester for Cryptography. Just posting it for anyone who wants to read it. We present a method for zero-knowledge, hash-based challenge-response network authentication in lieu of transmitting a password across the network. Zero-knowledge protocols, like our method, offer authentication alternatives to prevent [...]]]></description>
			<content:encoded><![CDATA[<p>This is a paper that Josh Hollenbeck, <a href="http://pdub.net/">Pat Wilbur</a>, and myself wrote last semester for Cryptography.  Just posting it for anyone who wants to read it.</p>
<blockquote><p>
We present a method for zero-knowledge, hash-based challenge-response network authentication in lieu of transmitting a password across the network. Zero-knowledge protocols, like our method, offer authentication alternatives to prevent a third-party from discovering a password after intercepting network data. Our method makes use of one-way hash functions to generate a response from a randomly-created challenge code supplied by an identity verifier. Our method also makes use of dynamic engagement for choosing which hash functions are used on a per-case basis, in order to thwart reversal of our method in the event of future discovery of weaknesses in any of the deployed hash functions.
</p></blockquote>
<p><a href='http://thecosmotron.com/wp-content/uploads/2009/01/paper.pdf'>Zero-Knowledge and You: A Beginner&#8217;s Guide to SPHiNX &#038; Challenge-Response Protocols</a> (PDF)</p>
<p><a href="http://thecosmotron.com/sphinx/">Webpage running SPHiNX</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thecosmotron.com/2009/01/29/zero-knowledge-and-you-a-beginners-guide-to-sphinx-challenge-response-protocols/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Numbers and NTL</title>
		<link>http://thecosmotron.com/2008/12/04/random-numbers-and-ntl/</link>
		<comments>http://thecosmotron.com/2008/12/04/random-numbers-and-ntl/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 01:36:39 +0000</pubDate>
		<dc:creator>Ryan Lewis</dc:creator>
				<category><![CDATA[Planet COSI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Update]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[ntl]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[random numbers]]></category>
		<category><![CDATA[seed]]></category>
		<category><![CDATA[ZZ]]></category>

		<guid isPermaLink="false">http://thecosmotron.com/?p=68</guid>
		<description><![CDATA[According to its website, the Number Theory Library (NTL) is a: high-performance, portable C++ library providing data structures and algorithms for manipulating signed, arbitrary length integers, and for vectors, matrices, and polynomials over the integers and over finite fields. I have been using it a lot because of the Cryptography class that I&#8217;m in this [...]]]></description>
			<content:encoded><![CDATA[<p>According to its website, the <a href="http://www.shoup.net/ntl/">Number Theory Library</a> (NTL) is a:</p>
<blockquote><p>high-performance, portable C++ library providing data structures and algorithms for manipulating signed, arbitrary length integers, and for vectors, matrices, and polynomials over the integers and over finite fields. </p></blockquote>
<p>I have been using it a lot because of the Cryptography class that I&#8217;m in this semester, and something that I need to do frequently is generate random numbers.</p>
<p>To do this, seeding is frequently required, and the NTL is no different, but it took a while for me to actually get it to work.  The following will seed the random functions provided by the NTL ZZ class:</p>
<pre>ZZ number, seed;
srand(getpid());
seed &lt;&lt; ((long) GetTime() ^ rand());
SetSeed(seed);
RandomLen(number, rand() % 300);</pre>
<p>Stick that at the top of your <code>main()</code> and you should be all set.</p>
<p>Also, does anyone know of a shorter, possibly easier to remember, way to do this?  If so, the comments are open.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecosmotron.com/2008/12/04/random-numbers-and-ntl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Samsung LN32A450, nVidia Drivers, and Ubuntu</title>
		<link>http://thecosmotron.com/2008/11/05/samsung-ln32a450-nvidia-drivers-and-ubuntu/</link>
		<comments>http://thecosmotron.com/2008/11/05/samsung-ln32a450-nvidia-drivers-and-ubuntu/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 06:43:08 +0000</pubDate>
		<dc:creator>Ryan Lewis</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Planet COSI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[samsung]]></category>
		<category><![CDATA[television]]></category>
		<category><![CDATA[x]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://thecosmotron.com/?p=54</guid>
		<description><![CDATA[I just recently purchased a Samsung LN32A450 television and wanted to use it as a monitor. I figured that it shouldn&#8217;t be too hard, just plug in my computer to it&#8217;s VGA port and then change the resolution. But, when are new things ever easy? To make a long story short, I had to generate [...]]]></description>
			<content:encoded><![CDATA[<p>I just recently purchased a Samsung LN32A450 television and wanted to use it as a monitor.  I figured that it shouldn&#8217;t be too hard, just plug in my computer to it&#8217;s VGA port and then change the resolution.  </p>
<p>But, when are new things ever easy?</p>
<p>To make a long story short, I had to generate a custom modeline for X to be able to use the TV&#8217;s native resolution, 1360&#215;768.  I read to use the command <code>cvt 1360 768 60.015Hz</code>, but the returned modeline resulted in a &#8220;Mode Not Supported&#8221; error from the TV.  Instead, I had to use a Windows program called <a href="http://www.entechtaiwan.net/util/ps.shtm">PowerStrip</a> to grab the custom timings that actually worked.  Though, the only reason they worked was by luck because Windows didn&#8217;t properly detect the monitor either, so I used PowerStrip to add a custom resolution to my registry which was preset with working timings.</p>
<p>Anyway, PowerStrip was nice enough to generate an xorg.conf modeline for me and had to edit the following in my file (this is assuming that you already have the proprietary nVidia drivers already working):</p>
<pre>
…

Section "Monitor"
    …
    Modeline "1360x768" 85.500 1360 1440 1552 1792 768 771 777 795 +hsync +vsync
EndSection

…

Section "Screen"
    …
    SubSection "Display"
        Depth  24
        Virtual 1360 768
        Modes "1360x768"
    EndSubSection
EndSection

…
</pre>
<p>Note: any ellipses (…) in the above are just cutting out parts that were not changed in my file.</p>
<p><strong>UPDATE:</strong> I figured that I would make a note that I recently tried getting a new computer to work with this television and didn&#8217;t have as much luck.  The new computer was using an ATI Radeon 4850 rather than the nVidia card that I got working previously.  Ultimately, I couldn&#8217;t get the VGA out to work and had to switch to using an HDMI connection.  After I did that, Ubuntu 8.10 (the same OS that I was using previously) automatically detected the native resolution of this TV.  Therefore, I recommend using HDMI over VGA to get this TV to work in Linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecosmotron.com/2008/11/05/samsung-ln32a450-nvidia-drivers-and-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Basic CouchDB w/ PHP Tutorial</title>
		<link>http://thecosmotron.com/2008/08/11/basic-couchdb-w-php/</link>
		<comments>http://thecosmotron.com/2008/08/11/basic-couchdb-w-php/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 18:20:59 +0000</pubDate>
		<dc:creator>Ryan Lewis</dc:creator>
				<category><![CDATA[Planet COSI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://thecosmotron.com/?p=49</guid>
		<description><![CDATA[I mentioned CouchDB in my last post, but didn&#8217;t really elaborate on what it was. Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API. Among other features, it provides robust, incremental replication with bi-directional conflict detection and resolution, and is queryable and indexable using a table-oriented view engine [...]]]></description>
			<content:encoded><![CDATA[<p>I mentioned <a href="http://incubator.apache.org/couchdb/">CouchDB</a> in my last post, but didn&#8217;t really elaborate on what it was.</p>
<blockquote><p>Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API. Among other features, it provides robust, incremental replication with bi-directional conflict detection and resolution, and is queryable and indexable using a table-oriented view engine with JavaScript acting as the default view definition language.</p></blockquote>
<p>I&#8217;m gonna show you some really basic ways to use CouchDB using a <a href='http://thecosmotron.com/wp-content/uploads/2008/08/CouchDB.php'>PHP class</a> found on their <a href="http://wiki.apache.org/couchdb/GettingStartedWithPhp">website</a> and assume that you have PHP 5.1 or greater and CouchDB 0.8 installed successfully.</p>
<p>The first thing that we need to do is create a sample database for us to play eventually play with using PHP.  To manage your databases and documents, you can use Futon, CouchDB&#8217;s administrative frontend.  It can be accessed at <a href="http://localhost:5984/_utils">http://localhost:5984/_utils</a>.  Create a database called &#8220;people&#8221; with two documents in it with random IDs that each have two fields in them: &#8220;name&#8221; and &#8220;age&#8221;.  Also, be sure to enter in some values for those.</p>
<p>Let&#8217;s look at this PHP file:</p>
<pre style="font-size:8pt; color:#005577;">
&lt;?php
include_once "CouchDB.php";

$couchdb = new CouchDB("people", "localhost");
$view = '{ "map": "function(doc) { emit(null, doc); }" }';

try {
  $all = $couchdb-&gt;send("/_temp_view", "post", $view)-&gt;getBody(true);
}
catch (CouchDBException $e) {
  die("[ERROR]".$e-&gt;getMessage()."\n");
}

foreach ($all-&gt;rows as $k =&gt; $row) {
  echo "Name: ".$row-&gt;value-&gt;name." / Age: ".$row-&gt;value-&gt;age."&lt;br/&gt;";
}
?&gt;</pre>
<p>This code is using a temporary view to query the database and then simply looping through the returned JSON and printing data from it.&nbsp; If you set up your database as I mentioned above, <code>$all</code> should be structured like this:</p>
<pre style="font-size:8pt; color:#005577;">
stdClass Object
(
  [total_rows] =&gt; 2
  [offset] =&gt; 0
  [rows] =&gt; Array
  (
    [0] =&gt; stdClass Object
    (
      [id] =&gt; 4144833052c61ab553875737b88ef91a
      [key] =&gt;
      [value] =&gt; stdClass Object
      (
        [_id] =&gt; 4144833052c61ab553875737b88ef91a
        [_rev] =&gt; 3595404992
        [name] =&gt; Ryan
        [age] =&gt; 20
      )
    )
    [1] =&gt; stdClass Object
    (
      [id] =&gt; ff3f20d54772b92aad43c36d6ed4abd1
      [key] =&gt;
      [value] =&gt; stdClass Object
      (
        [_id] =&gt; ff3f20d54772b92aad43c36d6ed4abd1
        [_rev] =&gt; 994830077
        [name] =&gt; Bob
        [age] =&gt; 40
      )
    )
  )
)</pre>
<p>When I visit the page running the script, it will therefore output this:</p>
<pre style="font-size:8pt; color:#005577;">
Name: Ryan / Age: 20
Name: Bob / Age: 40</pre>
<p>If anyone wants to see how to do something, just post a comment and I&#8217;ll try to whip something up.  Also, the <a href="http://wiki.apache.org/couchdb/FrontPage">CouchDB Wiki</a> has a lot more information if you&#8217;re interested.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecosmotron.com/2008/08/11/basic-couchdb-w-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic jQuery Form</title>
		<link>http://thecosmotron.com/2008/08/05/basic-jquery-form/</link>
		<comments>http://thecosmotron.com/2008/08/05/basic-jquery-form/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 18:25:50 +0000</pubDate>
		<dc:creator>Ryan Lewis</dc:creator>
				<category><![CDATA[Planet COSI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://thecosmotron.com/?p=41</guid>
		<description><![CDATA[I have been working on a web project at work for the past month and used it as an opportunity to learn jQuery and CouchDB. jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. While learning it, I [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a web project at work for the past month and used it as an opportunity to learn <a href="http://jquery.com/">jQuery</a> and <a href="http://incubator.apache.org/couchdb/">CouchDB</a>.</p>
<blockquote><p>jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages.</p></blockquote>
<p>While learning it, I found that there wasn&#8217;t a simple tutorial on how to make an ajax form, so here is one:</p>
<p>First, <a href="http://docs.jquery.com/Downloading_jQuery">download jQuery</a> from their website and rename the file to &#8220;jquery.js&#8221; (minus quotes).</p>
<p>Let&#8217;s create a file called form.html in the same folder as jquery.js:</p>
<pre style="font-size:8pt; color:#005577;">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Contact Form&lt;/title&gt;
    &lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
        $("#contact").submit(function(event) {
          event.preventDefault();
          $.ajax({
            type: "POST",
            url: "process_form.php",
            data: $(this).serialize(),
            success: function(html) {
              $("#info").html(html);
            },
            error: function() {
              alert("[ERROR] submit");
            }
          });
        });
      });
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form id="contact" action="process_form.php" method="POST"&gt;
      Name &lt;input type="text" name="name" /&gt;&lt;br /&gt;&lt;br /&gt;
      Email &lt;input type="text" name="email" /&gt;&lt;br /&gt;
      Message &lt;textarea name="msg"&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;

      &lt;input type="submit" name="submit" value="submit" /&gt;
    &lt;/form&gt;
    &lt;p id="info"&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Next, lets have a file called process_form.php, again in the same folder:</p>
<pre style="font-size:8pt; color:#005577;">&lt;?php
echo "Name: ".$_POST['name']."&lt;br /&gt;";
echo "Email: ".$_POST['email']."&lt;br /&gt;";
echo "Message: ".$_POST['msg'];
?&gt;
</pre>
<p>If you load up your pages via a working installation of a webserver with PHP installed, it should return what you entered into the form upon clicking submit. Now that it works, how about an explanation?</p>
<p>This is selecting the element with the id contact and binding to it&#8217;s submit event the proceeding function which is being passed event.data by jQuery</p>
<pre style="font-size:8pt; color:#005577;">$("#contact").submit(function(event) {</pre>
<p>Because event was passed to the function, we are now preventing the normal submit actions from being performed. So now when you click the submit button, the page wont refresh and the browser wont call the action script specified in the form tag.</p>
<pre style="font-size:8pt; color:#005577;">  event.preventDefault();</pre>
<p>This is how jQuery loads a page using HTTP request.  We specify that we want it use POST and the url to request.</p>
<pre style="font-size:8pt; color:#005577;">  $.ajax({
    type: "POST",
    url: "process_form.php",</pre>
<p>This is how we can send the data collected from the form to file being requested. <code>$(this)</code> is referring to the element with an id of contact and serialize is going to do just that: serialize the collected data into a string that can be sent in the request.</p>
<pre style="font-size:8pt; color:#005577;">    data: $(this).serialize(),</pre>
<p>This is the function to be called if the request succeeds. In our case, we are going to have it print all returned html into the element with id of info.</p>
<pre style="font-size:8pt; color:#005577;">    success: function(html) {
      $("#info").html(html);
    },</pre>
<p>This is called if the request fails for some reason.  In our case, an alert will pop up.</p>
<pre style="font-size:8pt; color:#005577;">    error: function() {
      alert("[ERROR] submit");
    }
  });
});</pre>
<p>That concludes this tutorial, if you want to read more about jQuery, there are <a href="http://docs.jquery.com/">tons of docs</a> on their official website.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecosmotron.com/2008/08/05/basic-jquery-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://thecosmotron.com/2006/03/08/hello-world/</link>
		<comments>http://thecosmotron.com/2006/03/08/hello-world/#comments</comments>
		<pubDate>Wed, 08 Mar 2006 19:41:30 +0000</pubDate>
		<dc:creator>Ryan Lewis</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thecosmotron.com/2006/03/08/hello-world/</guid>
		<description><![CDATA[#include &#60;iostream&#62; using std::cout; using std::endl; &#160; int main() { &#160;&#160;cout &#60;&#60; "Hello world!" &#60;&#60; endl; &#160;&#160;return 0; } There you go kiddies; I hope you have enjoyed my first blog post]]></description>
			<content:encoded><![CDATA[<div><code>#include &lt;iostream&gt;<br />
using std::cout;<br />
using std::endl;<br />
&nbsp;<br />
int main() {<br />
&nbsp;&nbsp;cout &lt;&lt; "Hello world!" &lt;&lt; endl;<br />
&nbsp;&nbsp;return 0;<br />
}</code></div>
<p>There you go kiddies; I hope you have enjoyed my first blog post</p>
]]></content:encoded>
			<wfw:commentRss>http://thecosmotron.com/2006/03/08/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
