Tech in the 603, The Granite State Hacker

Custom Guid’s

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;
using System.Linq;
    class Program
        static void Main(string[] args)
            GuidcustomGuid = GenerateCustomGuid();
        static Guid GenerateCustomGuid()
            //backwards, but required this to achieve desired result
            //Likely due to some standard with respect to bit order.
            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];
                    final[idx] = custom[idx];
            result = newGuid(final);

Example output:

0 thoughts on “Custom Guid’s”

Leave a Reply to Stacy Draper Cancel reply

Your email address will not be published. Required fields are marked *