Created
June 15, 2023 11:01
-
-
Save dariogriffo/f4d3ffcd83c8b7c606aabf9efcb14626 to your computer and use it in GitHub Desktop.
This file contains 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 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