<?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/"
		>
<channel>
	<title>Comments on: Generating a random PHP identifier</title>
	<atom:link href="http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/</link>
	<description>Just another technical blog</description>
	<lastBuildDate>Fri, 20 Aug 2010 08:53:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Andy</title>
		<link>http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/comment-page-1/#comment-59</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Sun, 31 May 2009 17:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.webtatic.com/?p=187#comment-59</guid>
		<description>Ah didn&#039;t notice that it was the default.

The php.net documentation usually says what version the functions and constants are available from. Not sure why it doesn&#039;t mentioned it.</description>
		<content:encoded><![CDATA[<p>Ah didn&#8217;t notice that it was the default.</p>
<p>The php.net documentation usually says what version the functions and constants are available from. Not sure why it doesn&#8217;t mentioned it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Maunders</title>
		<link>http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/comment-page-1/#comment-58</link>
		<dc:creator>Paul Maunders</dc:creator>
		<pubDate>Sun, 31 May 2009 16:57:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.webtatic.com/?p=187#comment-58</guid>
		<description>FILE_BINARY is only available in php 5.2.7 and above, so you get a PHP Notice:

Message: Use of undefined constant FILE_BINARY - assumed &#039;FILE_BINARY&#039;

It looks like you can simple replace that flag with null, as it&#039;s the default behaviour anyway, e.g.

$uniqueId = str_replace(
    				array(&#039;+&#039;,&#039;/&#039;,&#039;=&#039;),
   				array(&#039;-&#039;,&#039;_&#039;,&#039;&#039;),
    				base64_encode(file_get_contents(&#039;/dev/urandom&#039;, null, null, -1, 16)));</description>
		<content:encoded><![CDATA[<p>FILE_BINARY is only available in php 5.2.7 and above, so you get a PHP Notice:</p>
<p>Message: Use of undefined constant FILE_BINARY &#8211; assumed &#8216;FILE_BINARY&#8217;</p>
<p>It looks like you can simple replace that flag with null, as it&#8217;s the default behaviour anyway, e.g.</p>
<p>$uniqueId = str_replace(<br />
    				array(&#8216;+&#8217;,'/&#8217;,'=&#8217;),<br />
   				array(&#8216;-&#8217;,'_&#8217;,&#8221;),<br />
    				base64_encode(file_get_contents(&#8216;/dev/urandom&#8217;, null, null, -1, 16)));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/comment-page-1/#comment-52</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Sun, 03 May 2009 14:07:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.webtatic.com/?p=187#comment-52</guid>
		<description>I originally wrote the article thinking PHP integer&#039;s were 16 bit, that would have made 88 bits, but obviously they are 32 bits, so is a lot stronger.

Either way, md5ing seems a strange way to obfuscate into a 128 bit hash a random string with less randomness than 128 bits of random data.</description>
		<content:encoded><![CDATA[<p>I originally wrote the article thinking PHP integer&#8217;s were 16 bit, that would have made 88 bits, but obviously they are 32 bits, so is a lot stronger.</p>
<p>Either way, md5ing seems a strange way to obfuscate into a 128 bit hash a random string with less randomness than 128 bits of random data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/comment-page-1/#comment-51</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Sun, 03 May 2009 13:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.webtatic.com/?p=187#comment-51</guid>
		<description>Actually, I guess it would be better not to open a child process to read the file, I was just being lazy. I&#039;ve updated the post.

So it would be:
$random_url_string = str_replace(
array(’+&#039;,’/&#039;,’=&#039;),
array(’-&#039;,’_&#039;,”),
base64_encode(file_get_contents(&#039;/dev/urandom&#039;, FILE_BINARY, null, -1, 16)));</description>
		<content:encoded><![CDATA[<p>Actually, I guess it would be better not to open a child process to read the file, I was just being lazy. I&#8217;ve updated the post.</p>
<p>So it would be:<br />
$random_url_string = str_replace(<br />
array(’+&#8217;,’/&#8217;,’=&#8217;),<br />
array(’-&#8217;,’_&#8217;,”),<br />
base64_encode(file_get_contents(&#8216;/dev/urandom&#8217;, FILE_BINARY, null, -1, 16)));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Maunders</title>
		<link>http://www.webtatic.com/blog/2009/05/generating-a-random-php-identifier/comment-page-1/#comment-50</link>
		<dc:creator>Paul Maunders</dc:creator>
		<pubDate>Sun, 03 May 2009 10:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.webtatic.com/?p=187#comment-50</guid>
		<description>So would you ultimately recommend:

$random_url_string = str_replace(
    array(&#039;+&#039;,&#039;/&#039;,&#039;=&#039;),
    array(&#039;-&#039;,&#039;_&#039;,&#039;&#039;),
    base64_encode(`dd if=/dev/urandom bs=16 count=1`);</description>
		<content:encoded><![CDATA[<p>So would you ultimately recommend:</p>
<p>$random_url_string = str_replace(<br />
    array(&#8216;+&#8217;,'/&#8217;,'=&#8217;),<br />
    array(&#8216;-&#8217;,'_&#8217;,&#8221;),<br />
    base64_encode(`dd if=/dev/urandom bs=16 count=1`);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
