<?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>Michael Hartmayer - Portfolio &#187; Tripcode</title>
	<atom:link href="http://www.michaelhartmayer.com/tag/tripcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelhartmayer.com</link>
	<description>Have a Leet Smoothy</description>
	<lastBuildDate>Wed, 21 Jul 2010 04:04:47 +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>PHP TripCode</title>
		<link>http://www.michaelhartmayer.com/php/php-tripcode/</link>
		<comments>http://www.michaelhartmayer.com/php/php-tripcode/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 06:00:08 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tripcode]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=276</guid>
		<description><![CDATA[** EDIT ** I found some problems with my code. =) Did some research on PHP&#8217;s crypt() and found out that the salt doesn&#8217;t quite work they way I had expected it to. Going to post a revision soon. This is my version of a PHP TripCode (that I will be using for No-Mess-Enger). The [...]]]></description>
			<content:encoded><![CDATA[<p><em>** EDIT **<br />
I found some problems with my code. =) Did some research on PHP&#8217;s <strong>crypt()</strong> and found out that the salt doesn&#8217;t quite work they way I had expected it to. Going to post a revision soon.<br />
</em><br />
This is my version of a PHP <a href="http://en.wikipedia.org/wiki/Tripcode" target="_blank" title="WikiPedia: TripCode">TripCode</a> (that I will be using for No-Mess-Enger). The way it works is, the user chooses a name, and a key. That information along with the randomly generated URI generate an integer that will eventually be used to select a random animal or something like that. This will allow users to remain anonymous while upholding the integrity of the users authenticity, in case another user tries to choose the same name.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> utilMakeTripcode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$alias</span><span style="color: #339933;">,</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$uri</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;"># generate tripcode
</span>  <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">crypt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$alias</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$key</span>#<span style="color: #006699; font-weight: bold;">$uri</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>strlen<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$r</span><span style="color: #339933;">.=</span> <span style="color: #990000;">hexdec</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">bindec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Example:</p>
<p>- User enters the Alias: Jon<br />
- User enters the Key: SecretWord<br />
- The TripCode Int generated is <strong>101</strong></p>
<p>At this point I can use something like this to select the users animal:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$usersAnimal</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$allAnimals</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$maxAnimals</span><span style="color: #339933;">-</span><span style="color: #000088;">$maxAnimals</span><span style="color: #339933;">%</span><span style="color: #000088;">$tripCodeInt</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this example <strong>$allAnimals</strong> is an array holding every Animal name. $maxAnimals is the array size, and $tripCodeInt is the integer generated from the <strong>utilMakeTripCode()</strong> function. </p>
<p>So now when the user talks in Chat he might be called:<br />
Jon the <em>Koala</em></p>
<p><em>** Note **<br />
I&#8217;ve only TESTED the function. Can&#8217;t verify that the second snippet works exactly that way. It&#8217;s more pseudo code.. so don&#8217;t hate me if it&#8217;s not quite right. ^.^<br />
</em></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;bodytext=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;notes=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;t=PHP%20TripCode" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;annotation=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;t=PHP%20TripCode" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/php-tripcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
