public static void Main()
Console.WriteLine("FD00485F205A5C1B4C101E7D8DE3A107".ToOracleGuid());
public static class OracleTypeHelper
public static Guid ToOracleGuid(this string raw16String)
return new Guid(StringToBytes(raw16String));
private static byte[] StringToBytes(string hex)
throw new Exception("The hex string cannot have an odd number of digits");
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i)
arr[i] = (byte)((GetHexValue(hex[i << 1]) << 4) + (GetHexValue(hex[(i << 1) + 1])));
private static int GetHexValue(char hex)
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
public static string ToOracleString(this Guid self)
var bytes = self.ToByteArray();
int len = bytes.Length * 2;
char[] chars = new char[len];
chars[ci] = GetHexValue(b / 16);
chars[ci + 1] = GetHexValue(b % 16);
return new string(chars, 0, chars.Length);
private static char GetHexValue(int i)
return i < 10 ? (char)(i + 48) : (char)(i - 10 + 65);