0

Suppose we have an object like:

public class Record
{
    public string ServerID {get;set;}
    public string UID {get;set;}
}

ServerID and UID are long string keys, I am trying to make that two parameters to short readable string maximum 8 characters for end-user, I can Encode and Decode by below snipped code.

public static string Base64Encode(string plainText)
{
    var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
    return System.Convert.ToBase64String(plainTextBytes);
}
public static string Base64Decode(string base64EncodedData)
{
    var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
    return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}

For example I have something like: UID=1.2.840.113619.2.55.3.2831218035.988.1445761334.630&SystemID=BD99-370B-29C5-E424-5C61-0D70-E62B-5DDE

but unfortunately by Base64Encode it will be:
VUlEPTEuMi44NDAuMTEzNjE5LjIuNTUuMy4yODMxMjE4MDM1Ljk4OC4xNDQ1NzYxMzM0LjYzMCZTeXN0ZW1JRD1CRDk5LTM3MEItMjlDNS1FNDI0LTVDNjEtMEQ3MC1FNjJCLTVEREU=.

Is there a way to compress it something like VUlEPTEu and decode it to main version of string.

Aria
  • 3,724
  • 1
  • 20
  • 51

1 Answers1

0

Decrypt data with RijndaelManaged class (System.Security.Cryptography) . Some time ego i use this class and encrypted string was shorter than decrypted string.

P10trek
  • 167
  • 4
  • 15