SUUIDs

Mostly this is just farting around but I thought I’d post about it because it’s an interesting idea, at least in theory.

GUIDs are good but I wanted to do one better. So I created SUUIDs. Super Universally Unique IDs. The format of the current version, v2.0, is thus:

2/xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxx

Where x is a case-sensitive alphanumeric character. This gives us somewhere in the area of 3.35×10^64 possible combinations, and a lot of interesting characteristics.

  • For example, if the address space of a given ID is all hexadecimal, and the last four characters are IPv6, this functions just as well as an IPv6 address format. Thus, The IPv6 address 2001:0db8:0000:0000:0000:0000:1428:57ab is notated as 2/20010db8-00000000-00000000-142857ab-IPv6. If a field contains all the same character, you can replace the ending hyphen with a comma and the field with a single instance of that character, so that IP address could also be 2/20010db8-0,0,142857ab-IPv6.
  • In the same token, the same rules apply to a message that ends in 0MD5 — that’s an MD5 checksum as well as a unique address.

An implementation in Ruby:

	module SUUID
	  def self.gen
	   chars = ("a".."z").to_a + ("1".."9").to_a + ("A".."Z").to_a
	   x = [8, 8, 8, 8, 4]
	   x.map! {|i| i = Array.new(i, '').collect{chars[rand(chars.size)]}.join }
	   return "2/" + x.join('-')
	  end
	end

It’s not pretty, but it gets the job done. You could always throw a more random source of entropy at it, use the system date, time, whatever. Don’t particularly care about the implementation.

Here’s what a couple look like — to get used to the idea :-)

2/f9nuBgzm-HGTE4bSK-ZEfkfsRp-T3SXgpXA-5LNC
2/hoyOCd7o-V48NQGvv-OS5RBDIl-CG1FRNqG-Xd3j
2/sUZd6aGa-1J55rs9C-lxH1mvPA-I9PAvkOh-ZLVj

Additionally, you can omit the version number, which so far still allows for distinction between version 1 and version 2 (version 1 didn’t have lowercase letters). This means you have a nice set of directory names at your disposal.

mkdir /DOMejDTy-APESCioG-yyXpXBNL-lYAuQogL-Uep9
mkdir `curl -X POST http://example.com/suuid/provider`

I have no idea how checksums, hashes, verified randomness all fit into something like this. Just something fun and stupid to keep me occupied today.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*