<?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>Sean Jordan &#187; Tips</title>
	<atom:link href="http://seanjordan.me/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanjordan.me</link>
	<description>supernerd</description>
	<lastBuildDate>Wed, 25 Aug 2010 06:04:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Coding Pet-Peeve #1</title>
		<link>http://seanjordan.me/2010/07/coding-pet-peeve-1/</link>
		<comments>http://seanjordan.me/2010/07/coding-pet-peeve-1/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 06:28:41 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[coding pet-peeves]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=381</guid>
		<description><![CDATA[Variables declared, just for the sake of being returned. Example: function foo() { $a = 'bar'; return $a; } Try this, instead: function foo() { return 'bar'; } Simple, but this drives me nuts, and I see it all of the time.]]></description>
			<content:encoded><![CDATA[<p>Variables declared, just for the sake of being returned.</p>
<p>Example:</p>
<div class="code-section">
<pre>
function foo() {
    $a = 'bar';
    return $a;
}
</pre>
</div>
<p>Try this, instead:</p>
<div class="code-section">
<pre>
function foo() {
    return 'bar';
}
</pre>
</div>
<p>Simple, but this drives me nuts, and I see it all of the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2010/07/coding-pet-peeve-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running C/C++ Code as a CGI Script</title>
		<link>http://seanjordan.me/2009/11/running-c-cpp-code-as-a-cgi-script/</link>
		<comments>http://seanjordan.me/2009/11/running-c-cpp-code-as-a-cgi-script/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 08:25:06 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=129</guid>
		<description><![CDATA[When I first had the realization that this was not only possible, but really simple, I was very excited. Using C/C++ to create dynamic web applications isn&#8217;t new. In fact, C and Perl were originally the primary method for dynamic web based applications. Well, the Internet has been around long enough, that even Perl is [...]]]></description>
			<content:encoded><![CDATA[<p>When I first had the realization that this was not only possible, but really simple, I was very excited.  Using C/C++ to create dynamic web applications isn&#8217;t new.  In fact, C and Perl were originally the primary method for dynamic web based applications.  Well, the Internet has been around long enough, that even Perl is beginning to become obsolete (Thank God).</p>
<p>C++ Web applications are not going to be a game-changer.  If this were true, it would have happened a long time ago.  Will I forget about PHP? Of course not!  Many (probably most) shared hosting solutions won&#8217;t even allow you (with very good reason) to execute arbitrary binary files on their servers.  Mine won&#8217;t.  You also can&#8217;t (to my knowledge) do this technique on Windows servers.  </p>
<p>I WILL, probably, write a few C++ web applications to run on my laptop, just because I&#8217;m a nerd, and the satisfaction I&#8217;d get if from just knowing every time I hit the Home button, I&#8217;m seeing web pages dished up by a C++ script&#8230; I&#8217;ll stop there.</p>
<p>What kind of solutions do I see this as a replacement for PHP (or Ruby, or Python, or ASP, or JSP, or whatever you use)?  </p>
<ul>
<li>You are looking to build a robust web application to be run on your own private web servers.</li>
<p>I&#8217;m thinking, if Twitter was written in C/C++, we wouldn&#8217;t have as many Twitter-outages <img src='http://seanjordan.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  </p>
<li>You are looking to build a high-end distributable web-based software package.</li>
<p>For example, a software package, where the codebase sits on a server, and clients (or internal employees), interface with it through a web browser.  Now we&#8217;re talking APPLICATION, more than just a website.</p>
<li>You are looking to build a web application, and have the ability to run arbitrary binary scripts on your server (such as a private server), and runtime speed is crucial.</li>
<p>With FastCGI and precompiled binary scripts, well-written C/C++ code will trump compile-on-the-fly approaches of PHP, Perl, Python, etc.  (Of course PHP has memcache..)
</ul>
<p>Enough jibber-jabber. Let&#8217;s create a C++ CGI script!  First, you&#8217;ll need to configure Apache to execute CGI scripts.  It&#8217;s general practice (but you may not care.. I don&#8217;t) to create a single directory, and only allow CGI scripts in that directory to be executed.  You&#8217;ve probably seen a lot of cgi-bin/ directories on various websites.  Let&#8217;s say we create a directory at /var/www/cgi.  In this directory, we&#8217;ll put our CGI scripts.  Let&#8217;s tell Apache.</p>
<p>You&#8217;ll want to edit your httpd.conf file (on Ubuntu, it&#8217;s in /etc/apache2).  Add this (as root/sudo):</p>
<pre name="code" class="xml">
&lt;Directory /var/www/cgi&gt;
    Options ExecCGI+
    AddHandler cgi-script .cgi
&lt;/Directory&gt;
</pre>
<p>The <code>Options ExecCGI+</code> line is the one that allows CGI scripts to be executed.  If instead of using a single directory, you opted to make the whole ServerRoot allow CGI scripts (like I did), you&#8217;ll want to make sure the Options aren&#8217;t overridden elsewhere in the server conf.  Namely, check for something in /etc/apache2/sites-available/default (or where ever else your system may store Apache config).  In this file, You may see another <code>&lt;Directory&gt;</code> block for your server root.  Add ExecCGI to the Options list.</p>
<p>You can also create arbitrary file extensions for your CGI scripts with the <code>AddHandler</code> directive.  Imagine the possibilities.</p>
<p>Now, restart Apache.  On Ubuntu:</p>
<p><code>sudo /etc/init.d/apache2 restart</code></p>
<p>When Apache comes back up, you should be ready to roll.  You may feel like throwing in a test Perl script before we get to the C++, just to make sure things are working as expected.  If you aren&#8217;t a Perl Monk (most of us aren&#8217;t), do this:</p>
<p><code>which perl</code></p>
<p>Will tell you where perl is installed (if at all).  It&#8217;s probably /usr/bin/perl.  So then, create this Perl script:</p>
<pre name="code" class="perl">
#!/usr/bin/perl

print qq(Content-type: text/html\n\n);
print qq(Hello, world!);
</pre>
<p>Make sure to chmod that bad boy to at least 755, and hit it in the browser, you should see &#8220;Hello, world!&#8221;.  If not, you probably got one of these:</p>
<ul>
<li>You saw the perl code</li>
<p>   That means the CGI script didn&#8217;t attempt to execute, check back over the steps, make sure you restarted Apache.</p>
<li>You got Forbidden</li>
<p>   You either aren&#8217;t allowed to execute CGI scripts, or didn&#8217;t get the right permissions.</p>
<li>Internal Server Error</li>
<p>   Perl code is probably messed up.  Check out <code>tail /var/logs/apache2/error.log</code> for what SHOULD be a more detailed error message.</p>
<li>File not found</li>
<p>  You probably have a typo in the filename or the address bar <img src='http://seanjordan.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .
</ul>
<p>Well, hopefully you have that working now, lets throw down some C++ code.</p>
<p>I&#8217;m not going to teach you C++, so if this code doesn&#8217;t make sense, you should look into learning C++ before approaching this technique (obviously).</p>
<pre name="code" class="c++">

#include &lt;iostream&gt;
#include &lt;cstdlib&gt;

using namespace std;

int main() {

	cout &lt;&lt; "Content-type: text/html\n\n";
	cout &lt;&lt; "Hello World (Wide Web)&lt;br /&gt;" &lt;&lt; endl;

	cout &lt;&lt; getenv("REMOTE_ADDR") &lt;&lt; endl;

}
</pre>
<p>Save this as hello.C, or whatever you want.. and compile the code:</p>
<p><code>g++ -o hello.cgi hello.C</code></p>
<p>Now, make sure that hello.cgi is in /var/www/cgi (or wherever you specified), and hit it in the web browser.  You should see an output something like:</p>
<div class="code-section">
Hello World (Wide Web)<br />
127.0.1.1
</div>
<p>One of the biggest pitfalls I can foresee, is that server-side scripting is not an interactive technique.  Thats why scripting languages are perfect for dynamic web pages.  C++, not being a scripting language by nature may cause you some headaches.  Just be sure to write smart, efficient code.</p>
<p>You can also download a C++ CGI library, to help out with accessing header data, such as Cookies, GET and POST variables, etc. Here is a link to an <a href="http://www.boutell.com/cgic/#obtain">ANSI C library for CGI Programming</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/11/running-c-cpp-code-as-a-cgi-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Protecting Your Web Application&#8217;s Code</title>
		<link>http://seanjordan.me/2009/11/protecting-your-web-applications-code/</link>
		<comments>http://seanjordan.me/2009/11/protecting-your-web-applications-code/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 07:34:32 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=124</guid>
		<description><![CDATA[If you have ever considered commercial web application development, you&#8217;ve probably faced the challenge of protecting your intellectual property. I&#8217;ve spent the past few months researching and pondering this very problem. There are many possibilities and issues here. Dynamic web applications are generally written in a client-side scripting language. The nature of these scripting languages [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever considered commercial web application development, you&#8217;ve probably faced the challenge of protecting your intellectual property.  I&#8217;ve spent the past few months researching and pondering this very problem.</p>
<p>There are many possibilities and issues here.  Dynamic web applications are generally written in a client-side scripting language.  The nature of these scripting languages is to compile on-the-fly.  This means you store the code, in plain-sight.  Not very good when you&#8217;re trying to sell software, and anyone who purchases it has the ability to reverse engineer your product.  </p>
<p>Some technologies, such as JSP, allow you to compile the code down to bytecode, however, by nature of its design, Java bytecode is compact and simple to reverse engineer.  Encryption techniques such as ZendGuard are crackable (unencryption has to happen <em>somewhere</em>).  ActionScript (Flash) is promising, it compiles down to binary SWF files, however, tools exist to convert these SWF files into their FLA counterparts.</p>
<p>There may be no guaranteed, fool-proof way to protect your code, but one thing that has obviously worked well for stand-alone software vendors is binary compilation.  Great, so how do I compile my web code to binary?  Simple!  Just write your web applications in C/C++ (or other language that compiles to binaries), and run them as CGI scripts. </p>
<p>I had a major AH-HA moment, when I realized that all a CGI script needs to do, is print out the content MIME type, and the actual content, Apache will take care of the rest.  This approach will only work on Unix based hosts, as Windows does binaries a little different (suckers).  But as the vast majority of web hosts run on Unix, this isn&#8217;t a huge deal.</p>
<p>I&#8217;m going to create a 2nd post, demonstrating this technique.  Look for it in the not-so-distant future.</p>
<p>Update: The 2nd post is up! <a href="http://seanjordan.me/2009/11/running-c-cpp-code-as-a-cgi-script/" title="Running C/C++ Code as a CGI Script">Running C/C++ Code as a CGI Script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/11/protecting-your-web-applications-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prepared statements are not just for security</title>
		<link>http://seanjordan.me/2009/11/prepared-statements-are-not-just-for-security/</link>
		<comments>http://seanjordan.me/2009/11/prepared-statements-are-not-just-for-security/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 09:30:41 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=66</guid>
		<description><![CDATA[Prepared SQL statements are supported by a lot of database abstraction drivers. Prepared statements are great. If you aren&#8217;t using prepared statements, you should seriously look into it! Prepared statements are immune to SQL injection attacks. That&#8217;s right, immune. When you use prepared statements, you don&#8217;t have to worry about properly escaping inputs, it is [...]]]></description>
			<content:encoded><![CDATA[<p>Prepared SQL statements are supported by a lot of database abstraction drivers.  Prepared statements are great.  If you aren&#8217;t using prepared statements, you should seriously look into it!</p>
<p>Prepared statements are <strong>immune</strong> to SQL injection attacks.  That&#8217;s right, <strong>immune</strong>. When you use prepared statements, you don&#8217;t have to worry about properly escaping inputs, it is handled for you.</p>
<p>Aside from the security, prepared statements when you want to perform a query multiple times with different parameters.  The structure of prepared statements is intended just for that.  In fact, its the idea behind prepared statements.  Prepare the statement, run it several times with new sets of parameters.</p>
<p>The downside of prepared statements is the execution speed.  Before the query can be executed, it is &#8220;prepared&#8221; and parameters must be bound.  In a high-load setting, the increased execution time might be noticeable, but for average instances, its negligible.</p>
<p>When digging through old, crappy code, it is pretty common-place to see developers incorrectly using prepared statements.  How is this possible? Is it a vulnerability issue? Well, one of the main ideas behind a prepared statement, is that the statement may need to be executed several times, but the statement only needs to be &#8220;prepared&#8221; once.  If you have a loop which executes a query, prepare the statement before entering the loop. Inside the loop, you bind the parameters and execute.  <strong>Don&#8217;t prepare the statement inside the loop</strong>.</p>
<p>Preparing a statement is a string manipulation, doing it multiple times is extra load on precious CPU time.  I created a simple MySQL schema and PHP script to test this scenario, to get an idea of the extra execution time resulting in this improper usage of prepared statements.  The table I used simply had 3 fields:</p>
<p>id int unsigned not null auto_increment primary key,<br />
hash varchar(255) not null,<br />
hashType tinyint unsigned not null</p>
<p>The simple table and the fact that my laptop has virtually no load meant that the queries ran FAST.  20,000 executions took place in ~3 seconds.  I upped the number to 300,000 queries.  Preparing the statement 300,000 times resulted in a script execution time of 35 seconds (average over 3 trials), and preparing the statement once and then executing 300,000 times resulted in a script execution time of 33 seconds (average over 3 trials).</p>
<p>2 seconds isn&#8217;t significant, no, but this was on a dual-core laptop which saw the load peak at 0.61 during the trials.  Imagine this running on your shared hosting database.  On mine, I saw a 3 second difference when only running 5,000 queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/11/prepared-statements-are-not-just-for-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In response to my previous post&#8230;</title>
		<link>http://seanjordan.me/2009/10/in-response-to-my-previous-post/</link>
		<comments>http://seanjordan.me/2009/10/in-response-to-my-previous-post/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 07:48:04 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=43</guid>
		<description><![CDATA[My last post, Don&#8217;t store passwords as plain text! I described a simple method to create a salted hash of a password for a more secure method of storing it in a database.  If you haven&#8217;t already done so, you should read that post, to learn WHY its bad to store passwords as plain text [...]]]></description>
			<content:encoded><![CDATA[<p>My last post, <em><a href="http://seanjordan.me/2009/10/dont-store-passwords-as-plain-text/">Don&#8217;t store passwords as plain text!</a></em> I described a simple method to create a salted hash of a password for a more secure method of storing it in a database.  If you haven&#8217;t already done so, you should read that post, to learn WHY its bad to store passwords as plain text (if it isn&#8217;t obvious to you). I thought about the topic some more.  It is a very serious security issue, and so I decided that, if I&#8217;m going to make a post about the topic, I should be a little more informative.</p>
<p>I also read up a little on the topic.  It turns out that <a title="Coding Horror" href="http://www.codinghorror.com/blog/" target="_blank">Jeff Atwood</a> posted a pretty similiar <a title="Coding Horror: You're Probably Storing Passwords Incorrectly" href="http://www.codinghorror.com/blog/archives/000953.html" target="_blank">post</a> a couple years back.  Jeff made an assertion that I should make as well.  Like Jeff, I am not a cryptographer, so don&#8217;t trust my advice like I am a security EXPERT.  He also taught me about <a title="Wikipedia: Rainbow Tables" href="http://en.wikipedia.org/wiki/Rainbow_tables" target="_blank">rainbow tables</a>.  Rainbow tables, in short, are a massive database of precomputed hashes.  With our hash inside of a hash technique, the final hash product is too long for modern rainbow tables to be effective.  This is great and all, but there are a few problems with my method.  One thing you need to realize when dealing with system security is there will almost ALWAYS be security holes.  We do our best to prevent them, but we can&#8217;t promise to be 100% successful.</p>
<p>I&#8217;m going to revisit the salted hash to create a better salting, hashing, hacker-hater method of storing passwords.  I&#8217;ll make another disclaimer-like notice first.  Most people use only a handful of unique passwords (and by handful, I mean: one.. or two) across a galaxy of login systems.  If you develop a system to store a user&#8217;s password it is your responsibility to store it in the most secure way you can.  I don&#8217;t recommend you use my salty hash method, I simply mean for it to be an enlightening moment of: &#8220;Oh crap, I should really think about how I&#8217;m storing my users&#8217; passwords.&#8221;  There are always security holes.  I&#8217;ve already thought about one in my original.  I thought my method worked well, because the salt wasn&#8217;t exposed in the stored value. I liked this, but then realized a problem: two user&#8217;s with the same password will generate the same hash.  This is much the problem with storing a non-salted hash, and is the principle used in cracking hashes via brute force/rainbow table.  Hashing strings until the two generated hashes match.</p>
<p>Here is my improved method, in (PHP) code:</p>
<pre name="code" class="php">
// our password this time, is a little bit stronger than ‘password’
$password = “#aBc.123@”;

// some alpha-numeric values and special characters, for use in our salt
$salt_material = “abcdefghijklmnopqrstuvwxyz1234567890 \”!@#$%^&amp;*()_=+-{}[],./&lt;&gt;?;’:”;

// salt will be a string of random length, 1-9
$salt_length = rand(1,9);
$salt = “”;

//build the salt from our material at random choice
for($i = 0; $i &lt; $salt_length; $i++) {
$salt .= $salt_material[ rand(0, strlen($salt_material)-1) ];
}

// calculate the hashes, and then reverse the strings
// not sure about the added strength, but I like the idea of reversing the sums
$salt_sum = strrev( md5($salt) );
$password_sum = strrev( md5($password) );

// now create the sum of our salt + password
$salty_hash = md5( $salt_sum . $password_sum );

// create a hash which exposes our salt, so we know what it was.
// since our salt_length is only 1-9, this information doesn’t have to be
// separated, its always the first char
$resulting_hash = $salt_length . $salt . $salty_hash;

// for added measure, an idea I read elsewhere.
// again, not sure about the added strength, but I like the idea of it
$secure_hash = sha1($resulting_hash);

// and now, the final result
$final_product = $salt_length . $salt . $secure_hash;
</pre>
<p>Now, each time the hash is calculated, it should be a unique value, however we should be able to recreate it (provided the user inputs the correct password).  Four runs of the script resulted in the following hashes:</p>
<p>7{5@a#@@f77a51b733b65590d284b990099fc764239fbd63<br />
4n+b44c38fe32b4f9a095d7534610bce0f4d72d2976f7<br />
9r{j&amp;f2i&#8221;t9ea7035cf81de87a07980e9884d26db67e510728<br />
4;xd&#8221;a9ff52b67313cc2d183b977226747a6685540a43</p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/10/in-response-to-my-previous-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t store passwords as plain text!</title>
		<link>http://seanjordan.me/2009/10/dont-store-passwords-as-plain-text/</link>
		<comments>http://seanjordan.me/2009/10/dont-store-passwords-as-plain-text/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 23:46:43 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=31</guid>
		<description><![CDATA[Many websites will email your password to you if you have forgotten it.  When I create a new account on a website, I don&#8217;t want them to know my password!  They shouldn&#8217;t be storing my password somewhere as plain text.  Granted, the site could be storing a hashed version, and simply using an algorithm to [...]]]></description>
			<content:encoded><![CDATA[<p>Many websites will email your password to you if you have forgotten it.  When I create a new account on a website, I don&#8217;t want them to know my password!  They shouldn&#8217;t be storing my password somewhere as plain text.  Granted, the site could be storing a hashed version, and simply using an algorithm to unhash it, and send you back the unhashed version, but I don&#8217;t like this either.  I don&#8217;t want them to even be able to unhash my password!</p>
<p>No hashing algorithm is completely unbreakable.  Hashing algorithms such as MD5 or SHA-1 have been shown to be breakable (MD5 much more easily than SHA-1), but storing the MD5 hash of a password is still SIGNIFICANTLY more secure than storing the plain text, or an easily crackable custom hashing algorithm.  Cracking an MD5 sum can take a few minutes, several hours, or even days, depending on the CPU power available, SHA-1 even longer.</p>
<p>We can create an even more secure hash by combining the efforts of a custom hashing algorithm and MD5 to create a unique custom hashing mechanism.  This is an example of how you should store your users&#8217; passwords. We want to &#8220;salt&#8221; the original string, and then hash the salted version, and store only the hash.  When it comes time to authenticate a user&#8217;s login attempt, we run their input through the hashing function.  If the two hashes match, they&#8217;ve inserted the correct password.</p>
<p>Here is an example of such a custom salted hash:</p>
<p>Our string to be hashed is &#8220;password.&#8221; First, let&#8217;s come up with a salting mechanism.  For this example, we&#8217;ll use something simple.  The salt used has to be retrievable and positively recreatable. &#8220;Password&#8221; has 8 characters.  Lets take (in PHP)</p>
<p><code>$salt = floor(strlen("password") / 2);</code></p>
<p>That is the length of the string, divided by two, rounded down to the nearest whole number.  In our case the answer is 4.  floor() does nothing for us here, but if the string length is odd we want a whole number, and we want the same whole number every time a string of that length is used.</p>
<p>Now we have our salt, 4.  Let&#8217;s hash up the 4.</p>
<p><code>$salt_sum = md5( decbin($salt) );</code></p>
<p>I took 4, converted it to binary (results in 100), and found the MD5 sum of that as a string, the result is: f899139df5e1059396431415e770c6dd</p>
<p>Lets prepend that to our input string, &#8220;password&#8221; and find the MD5 sum:</p>
<p><code>$hash = md5($salt_sum . "password");</code></p>
<p>Now, our result is: c88e94b4d0f8e1c303f3b79d131a2d13 &#8212; and THAT is what we want to store.  Now we can recreate that, and now our MD5 sum is incredibly difficult to break, with the pre-hashed value containing a 32 character &#8220;random&#8221; string, plus the original 8.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/10/dont-store-passwords-as-plain-text/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting started with Linux and the Command Line</title>
		<link>http://seanjordan.me/2009/10/getting-started-with-linux-and-the-command-line/</link>
		<comments>http://seanjordan.me/2009/10/getting-started-with-linux-and-the-command-line/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 08:30:44 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=22</guid>
		<description><![CDATA[Linux is great.  If you are in to developing websites, chances are, you&#8217;ll be working with Linux.  Problem is, a lot of people are afraid of the command line, or just don&#8217;t know enough commands to be comfortable working on a server via SSH. Here are a few commands you&#8217;ll need to know to get [...]]]></description>
			<content:encoded><![CDATA[<p>Linux is great.  If you are in to developing websites, chances are, you&#8217;ll be working with Linux.  Problem is, a lot of people are afraid of the command line, or just don&#8217;t know enough commands to be comfortable working on a server via SSH.</p>
<p>Here are a few commands you&#8217;ll need to know to get started:</p>
<p>1. cd</p>
<p>cd stands for &#8216;change directory&#8217; and is one you&#8217;ll probably use most frequently.  The syntax is very simple:</p>
<p>cd <em>destination</em></p>
<p>A few tricks to know when working with this command:</p>
<p>cd ..</p>
<p>Changes to the directory UP one hierarchical level.</p>
<p>cd ../..</p>
<p>Changes to the director UP two hierarchical levels.. etc.</p>
<p>cd ../myFolder</p>
<p>Changes to a folder called &#8216;myFolder&#8217; which is a subfolder of the current parent folder.  This is a <em>relative</em> path.</p>
<p>cd /</p>
<p>Changes to the root folder of the filesystem.</p>
<p>cd /var/www</p>
<p>Change to an <em>absolute</em> path.</p>
<p>cd ~</p>
<p>Change to your shell&#8217;s home directory.  By default, this is your system home directory, such as /home/yourUsername</p>
<p>cd ~/Desktop</p>
<p>Change to the Desktop folder under your home directory, equivalent to something such as cd /home/yourUsername/Desktop</p>
<p>2. cp</p>
<p>cp is the copy command, and is another frequently used command.  This is another command with very simple syntax.  Learning the syntax of cd is useful for using cp. The syntax is:</p>
<p>cp file-to-be-copied.php /destination/newfilename.php</p>
<p>Here are a few examples and tips for working with cp:</p>
<p>cp index.php home.php</p>
<p>Creates a copy of the index.php file, named home.php</p>
<p>cp index.php /someDirectory</p>
<p>Creates an index.php under the folder /someDirectory.  Not supplying the new name gives the copy the same name, index.php</p>
<p>cp someDirectory/ /destination/</p>
<p>Creates a folder &#8216;someDirectory&#8217; under the &#8216;/destination&#8217; folder.  This doesn&#8217;t copy any of the files, just the folder itself.</p>
<p>cp someDirectory/ newDirectoryName/</p>
<p>Creates a folder in the same directory with the name &#8216;newDirectoryName&#8217; .. again, no files are copied just the folder (and its ownership/permissions). Apply a relative or absolute path before the directory name to create it somewhere else.</p>
<p>cp -r someDirectory/ newDirectoryName/</p>
<p>Creates a copy of the directory &#8216;someDirectory&#8217; named &#8216;newDirectoryName&#8217;.  using the &#8216;-r&#8217; flag will copy the folders contents &#8220;recursively.&#8221;</p>
<p>3. ls</p>
<p>ls is the command used to list all of the files in your present working directory.  It is as simple as typing: ls.  You can add flags for more views:</p>
<p>ls -a</p>
<p>will show you ALL files .. includes the hidden files (hidden files start with period, such as &#8220;.htaccess&#8221;)</p>
<p>ls -l</p>
<p>will show you the files in a list format. This method shows you more information about the file, such as the owner, the size, and the last modification date.</p>
<p>Combine the two flags, to get ls -al and you will see all files in a list format</p>
<p>4. pwd</p>
<p>pwd echoes out your &#8220;Present Working Directory&#8221; to the screen.  Cool.</p>
<p>5. rm</p>
<p>rm is the always useful remove command.  Type</p>
<p>rm filename.php</p>
<p>to remove the file &#8216;filename.php&#8217;. There are a lot of flags to be used with rm, but they can be dangerous. We&#8217;ll wait until you are more comfortable in the command line.</p>
<p>6. rmdir</p>
<p>rmdir is rm&#8217;s brother. rmdir clearly stands for &#8220;Remove Directory&#8221;.  You can only remove a directory that is empty.  If its not empty, you&#8217;ll first need to delete all of the files in the directory.  There are easier ways to remove things in bulk, or to remove non-empty directories, but as I said, they can be dangerous.  We&#8217;ll wait until you are more comfortable in the command line. <img src='http://seanjordan.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>7. mv</p>
<p>mv stands for Move.  It is the command you&#8217;ll use to relocate files.  You can consider moving a file to be the same thing as renaming it.  Renaming a file from &#8220;fileA.php&#8221; to &#8220;fileB.php&#8221; is the same as moving its location to be &#8220;/directory/fileA.php to /directory/fileB.php.</p>
<p>Use mv as:</p>
<p>mv fileA.php fileB.php</p>
<p>to rename fileA to fileB.  Or you can use mv like:</p>
<p>mv fileA.php /some/other/dir/</p>
<p>to relocate fileA.php to /some/other/dir/fileA.php</p>
<p>This is all I have for now.  There will hopefully be more later.  Enjoy, n00bs <img src='http://seanjordan.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/10/getting-started-with-linux-and-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A handful of awesome websites</title>
		<link>http://seanjordan.me/2009/10/a-handful-of-awesome-websites/</link>
		<comments>http://seanjordan.me/2009/10/a-handful-of-awesome-websites/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 08:35:51 +0000</pubDate>
		<dc:creator>Sean Jordan</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Websites]]></category>

		<guid isPermaLink="false">http://seanjordan.me/?p=27</guid>
		<description><![CDATA[Here is a handful of websites that I&#8217;ve found to be just plain awesome.  If you, too, create web pages for a living, I think you&#8217;ll dig. Iconfinder.net WebDesignDev GeoCities Quirksmode InstantDomainSearch Cooltext (For those not so professional in photoshop or gimp) Logomaker That&#8217;s all I got right now.  This is what I use a [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a handful of websites that I&#8217;ve found to be just plain awesome.  If you, too, create web pages for a living, I think you&#8217;ll dig.<a title="Iconfinder" href="http://www.iconfinder.net/"></a></p>
<ol>
<li><a title="Iconfinder" href="http://www.iconfinder.net/">Iconfinder.net</a></li>
<li><a title="WebDesignDev" href="http://www.webdesigndev.com/">WebDesignDev</a></li>
<li><span style="text-decoration: line-through;">GeoCities</span> <img src='http://seanjordan.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a title="Quirksmode" href="http://www.quirksmode.org/">Quirksmode</a></li>
<li><a title="InstantDomainSearch" href="http://www.instantdomainsearch.com">InstantDomainSearch</a></li>
<li><a title="Cooltext" href="http://cooltext.com/">Cooltext</a> (For those not so professional in photoshop or gimp)</li>
<li><a title="Logomaker" href="http://www.logomaker.com/">Logomaker</a></li>
</ol>
<p>That&#8217;s all I got right now.  This is what I use a lot for inspiration or resources.  You should already be  aware of most, if not all, of these sites.  Just giving them their due respect.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanjordan.me/2009/10/a-handful-of-awesome-websites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
