Skip to content

Instantly share code, notes, and snippets.

@dariogriffo
Created June 15, 2023 11:01
Show Gist options
  • Save dariogriffo/f4d3ffcd83c8b7c606aabf9efcb14626 to your computer and use it in GitHub Desktop.
Save dariogriffo/f4d3ffcd83c8b7c606aabf9efcb14626 to your computer and use it in GitHub Desktop.
public static class GuidSteganography
{
public static Guid Hide(this Guid id, short value)
{
byte[] span = id.ToByteArray();
int i = value * 16 - 15;
span[7] = (byte)(span[7] + i);
return new Guid(span);
}
public static short Reveal(this Guid id)
{
int a = (((Convert.ToInt16(id.ToByteArray()[7]) ^ 0x0F) + 15) / 16);
return (short)(a < 4 ? a + 12 : a - 4);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment