-
-
Save khellang/04292b0d3be5e94878043e0db0e8f411 to your computer and use it in GitHub Desktop.
Xor combination of two Guids.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Guid Xor(Guid a, Guid b) | |
{ | |
var ad = new DecomposedGuid(a); | |
var bd = new DecomposedGuid(b); | |
ad.Hi ^= bd.Hi; | |
ad.Lo ^= bd.Lo; | |
return ad.Value; | |
} | |
[StructLayout(LayoutKind.Explicit)] | |
private struct DecomposedGuid | |
{ | |
[FieldOffset(00)] public Guid Value; | |
[FieldOffset(00)] public long Hi; | |
[FieldOffset(08)] public long Lo; | |
public DecomposedGuid(Guid value) : this() => Value = value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, that's what I expected ๐๐