I need it very simply, but before I invent the wheel, I would like to know if there is something like that within the existing ones.
I would like to encode (and decrypt) strings from a table of predefined characters. I have many lines containing multiple characters. Here is the line I would like to encode:
cn = 1; pl = 23; 3 = VF; st = 0
This line size is 20 characters, so 20 bytes.
In the string, I use only the following characters: cn = 1; p23vf0
Only 11 characters. So each character can be encoded with 4 bits just not? Decrease the total number of bytes used for 10.
Is there any existing method in .NET that can take a string in a parameter and an array of a reference table and return encoded bytes?
char [] reference = "cn = 1; p23vf0" .ToCharArray (); string input = "cn = 1; pl = 23; vf = 3; vv = 0";
byte [] encoded = someClass.Encode (input, link); string decoded = someClass.Decode (encoded, link);
Assert.AreEqual (input, decoding);
user333306
source
share