All pastes #375352 Raw Edit

guidpacker

public text v1 · immutable
#375352 ·published 2007-02-28 06:45 UTC
rendered paste body
public byte[] GetPackedGUID(ulong guid)
        {
            byte[] guidBytes = BitConverter.GetBytes(guid);
            List<byte> packedGUID = new List<byte>();
            packedGUID.Add(0); // mask
            for (int i = 0; i < 8; i++)
            {
                if (guidBytes[i] != 0)
                {
                    packedGUID[0] |= (byte)(1 << i);
                    packedGUID.Add(guidBytes[i]);
                }
            }
            return packedGUID.ToArray();
        }