<?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: Guid0: JavaScript GUIDs</title>
	<atom:link href="http://ajaxian.com/archives/guid0-javascript-guids/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/guid0-javascript-guids</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Mon, 15 Mar 2010 01:28:22 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: broofa</title>
		<link>http://ajaxian.com/archives/guid0-javascript-guids/comment-page-1#comment-269114</link>
		<dc:creator>broofa</dc:creator>
		<pubDate>Sun, 16 Nov 2008 01:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5061#comment-269114</guid>
		<description>In a shameless act of self-promotion, I&#039;ll point readers at the &lt;a href=&quot;http://www.broofa.com/blog/?p=151&quot; rel=&quot;nofollow&quot;&gt;randomUUID.js&lt;/a&gt; script I created, which was &lt;a href=&quot;http://ajaxian.com/archives/uuid-generator-in-javascript&quot; rel=&quot;nofollow&quot;&gt;covered in Ajaxian here&lt;/a&gt;.  Originally designed to produce RFC 4122-compliant IDs, it can also generate non-standard IDs of any length using 62 character base. There&#039;s &lt;a href=&quot;http://www.broofa.com/Tools/randomUUID.htm&quot; rel=&quot;nofollow&quot;&gt;a demo here&lt;/a&gt;, which shows usage, resulting IDs, and the possible number of ids for each invocation.

@Michael: You should check out the &quot;version 4&quot; format of GUID allowed by RFC4122.  That&#039;s what the randomUUID.js script produces, and it is trivial to generate.  It&#039;s also a *much* more appropriate form for javascript where timestamps and unique values (based on IP address or whatever) are not available.  It&#039;s also has a much larger UUID &quot;space&quot; since 122 of the 128 bits are randomly generated. 

Regarding your API, I think you can significantly simplify it by using the &lt;a href=&quot;http://yuiblog.com/blog/2007/06/12/module-pattern/&quot; rel=&quot;nofollow&quot;&gt;module pattern&lt;/a&gt;.  This will let you make all the constants truely private.  More importantly, you can make your log() method private as well, and thereby avoid clobbering any log method that users of your script may have defined.</description>
		<content:encoded><![CDATA[<p>In a shameless act of self-promotion, I&#8217;ll point readers at the <a href="http://www.broofa.com/blog/?p=151" rel="nofollow">randomUUID.js</a> script I created, which was <a href="http://ajaxian.com/archives/uuid-generator-in-javascript" rel="nofollow">covered in Ajaxian here</a>.  Originally designed to produce RFC 4122-compliant IDs, it can also generate non-standard IDs of any length using 62 character base. There&#8217;s <a href="http://www.broofa.com/Tools/randomUUID.htm" rel="nofollow">a demo here</a>, which shows usage, resulting IDs, and the possible number of ids for each invocation.</p>
<p>@Michael: You should check out the &#8220;version 4&#8243; format of GUID allowed by RFC4122.  That&#8217;s what the randomUUID.js script produces, and it is trivial to generate.  It&#8217;s also a *much* more appropriate form for javascript where timestamps and unique values (based on IP address or whatever) are not available.  It&#8217;s also has a much larger UUID &#8220;space&#8221; since 122 of the 128 bits are randomly generated. </p>
<p>Regarding your API, I think you can significantly simplify it by using the <a href="http://yuiblog.com/blog/2007/06/12/module-pattern/" rel="nofollow">module pattern</a>.  This will let you make all the constants truely private.  More importantly, you can make your log() method private as well, and thereby avoid clobbering any log method that users of your script may have defined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Mahemoff</title>
		<link>http://ajaxian.com/archives/guid0-javascript-guids/comment-page-1#comment-269097</link>
		<dc:creator>Michael Mahemoff</dc:creator>
		<pubDate>Fri, 14 Nov 2008 14:16:56 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5061#comment-269097</guid>
		<description>Spocke, that&#039;s correct. One could try and use the IP number in place of the MAC address (or a cookie if available), for example, but as with the MAC solutions, there are privacy and security concerns. You can deal with them to some extent using encryption techniques, leading to a long hash, but my immediate objective with this library was to create small strings. 

With a 128-bit GUID, though, the probability of a collision is extremely low. There&#039;s 32 bits for the timestamp (until 2038) and 96 left over. There&#039;s also a counter sequence of several bits to ensure an individual client doesn&#039;t collide with itself, leaving around 80-90 bits for randomness. So if you and someone else generate a timestamp in the same MILLISECOND, already very unlikely, you have a 1 in 2^86 chance of a collision. For most systems, such as the comments plugin I&#039;m working on, this is something I can live with, and in many cases worth the trade-off over using an IP address. (Needs further back-of-the-napkin probability analysis!).

This all assumes a good random number algorithm. Since Javascript doesn&#039;t actually let you seed randomness, that&#039;s a serious concern, and it may be wise to use an API like this http://json-random.appjet.net/ where accessible.</description>
		<content:encoded><![CDATA[<p>Spocke, that&#8217;s correct. One could try and use the IP number in place of the MAC address (or a cookie if available), for example, but as with the MAC solutions, there are privacy and security concerns. You can deal with them to some extent using encryption techniques, leading to a long hash, but my immediate objective with this library was to create small strings. </p>
<p>With a 128-bit GUID, though, the probability of a collision is extremely low. There&#8217;s 32 bits for the timestamp (until 2038) and 96 left over. There&#8217;s also a counter sequence of several bits to ensure an individual client doesn&#8217;t collide with itself, leaving around 80-90 bits for randomness. So if you and someone else generate a timestamp in the same MILLISECOND, already very unlikely, you have a 1 in 2^86 chance of a collision. For most systems, such as the comments plugin I&#8217;m working on, this is something I can live with, and in many cases worth the trade-off over using an IP address. (Needs further back-of-the-napkin probability analysis!).</p>
<p>This all assumes a good random number algorithm. Since Javascript doesn&#8217;t actually let you seed randomness, that&#8217;s a serious concern, and it may be wise to use an API like this <a href="http://json-random.appjet.net/" rel="nofollow">http://json-random.appjet.net/</a> where accessible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spocke</title>
		<link>http://ajaxian.com/archives/guid0-javascript-guids/comment-page-1#comment-269093</link>
		<dc:creator>Spocke</dc:creator>
		<pubDate>Fri, 14 Nov 2008 12:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5061#comment-269093</guid>
		<description>Is it just me or isn&#039;t guids supposed to be globally unique and include the mac address of the computer or something else that seeds the key generation for a specific user session. I know this isn&#039;t possible to do using Javascript but if the guid isn&#039;t really unique whats the point of using it. When the same guid can be generated on two separate machines by accident. At least it shouldn&#039;t be called guid since it doesn&#039;t live up to it&#039;s name.</description>
		<content:encoded><![CDATA[<p>Is it just me or isn&#8217;t guids supposed to be globally unique and include the mac address of the computer or something else that seeds the key generation for a specific user session. I know this isn&#8217;t possible to do using Javascript but if the guid isn&#8217;t really unique whats the point of using it. When the same guid can be generated on two separate machines by accident. At least it shouldn&#8217;t be called guid since it doesn&#8217;t live up to it&#8217;s name.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
