126
Console.WriteLine("out CGUID "+ outGuid.ToString("B").ToUpper()+" before full compression (removal of dashes) here for readability"); //for readability
1
using System;
2
using System.Collections.Generic;
3
4
//###################################################################################################
5
//https://metadataconsulting.blogspot.com/2019/11/C-Sharp-Convert-a-GUID-to-a-Compressed-GUID.html
6
//###################################################################################################
7
public class Program
8
{
9
public static bool IsHex(IEnumerable<char> chars)
10
{
11
bool isHex;
12
foreach(var c in chars)
13
{
14
isHex = ((c >= '0' && c <= '9') ||
15
(c >= 'a' && c <= 'f') ||
16
(c >= 'A' && c <= 'F'));
17
18
if(!isHex)
19
return false;
20
}
21
return true;
22
}
23
public static void Main()
24
{
Cached Result
Input GUID {12345678-ABCD-EFAB-1234-ABCDEFABCDEF} is valid? True
out CGUID {87654321-DCBA-BAFE-2143-BADCFEBADCFE} before full compression (removal of dashes) here for readability
Compressed guid is 87654321DCBABAFE2143BADCFEBADCFE
Matched expectations.
Input Compressed GUID 87654321DCBABAFE2143BADCFEBADCFE
Output Decomprsd GUID 12345678ABCDEFAB1234ABCDEFABCDEF this line for comparison only
Decompressed compressed guid is {12345678-ABCD-EFAB-1234-ABCDEFABCDEF}
out CGUID {87654321-DCBA-BAFE-2143-BADCFEBADCFE} before full compression (removal of dashes) here for readability
Compressed guid is 87654321DCBABAFE2143BADCFEBADCFE
Matched expectations.
Input Compressed GUID 87654321DCBABAFE2143BADCFEBADCFE
Output Decomprsd GUID 12345678ABCDEFAB1234ABCDEFABCDEF this line for comparison only
Decompressed compressed guid is {12345678-ABCD-EFAB-1234-ABCDEFABCDEF}