Caught a question from Stacy Draper, @StacyDraper this morning about custom guids, to make them more recognizable.
It reminded me of a post I saw recently about Facebook using hex characters to make IPv6 addresses more recognizable.
Here’s what I was thinking… create a guid that has an embedded word.
For example, the following code creates a Guid that always starts with FACEB00C:
using System.Linq;
usingSystem.Text;
namespaceCustomGuidTest
{
class Program
{
static void Main(string[] args)
{
GuidcustomGuid = GenerateCustomGuid();
Console.WriteLine(customGuid.ToString(“B”));
Console.ReadKey();
}
static Guid GenerateCustomGuid()
{
Guidresult;
//0xFACEB00C
//backwards, but required this to achieve desired result
byte[] custom = new byte[] { 0x0C, 0xB0, 0xCE, 0xFA };
byte[] random = Guid.NewGuid().ToByteArray();
byte[] final = new byte[16];
for(int idx = 0; idx <16; idx++)
{
if(idx >= custom.Length)
{
final[idx] = random[idx];
}
else
{
final[idx] = custom[idx];
}
}
result = newGuid(final);
returnresult;
}
}
}
{faceb00c-7828-4e99-8cf5-280e33202670}
I wrote some code and described it here http://wildwires.com/blog/12-06-09/Is_it_so_wrong_to_seed_your_GUID.aspx and then I made it useful to others here http://wildwires.com/Products/GUID.aspx Thanks for your help and inspiration
Thanks, Stacy… always fun playing with the more esoteric stuff! 🙂