/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// using System; using System.Text; using System.Threading.Tasks; namespace wasSharp { public static class Extensions { /// /// Combine two UUIDs together by taking the MD5 hash of a byte array /// containing both UUIDs /// /// First UUID to combine /// Second UUID to combine /// The UUID product of the combination public static Guid CombineXOR(this Guid p, Guid q) { var l = p.ToByteArray(); var r = q.ToByteArray(); byte[] combine = new byte[16]; Parallel.For(0, 16, i => { combine[i] = (byte)(l[i] ^ r[i]); }); return new Guid(combine); } /// /// Converts a byte array to a hexadecimal string. /// /// /// public static string ToHexString(this byte[] bytes) { StringBuilder str = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) str.AppendFormat("{0:X2}", bytes[i]); return str.ToString(); } } }