I want to shrink Strings like -1234B56789C;ABC1D3E/FGH4IJKL
which are approx 20 - 25 case-insensitive chars.
My goal is to have an alphanumeric string that is a maximum of 16
characters. They must remain human readable.
Is that possible? Are there algorithms that can be used to compress alphanumeric string that also has some special chars?
It must also be possible to revert the compression.
I think in general it's not possible unless you use a different target alphabet.
As far as I understand currently your source alphabet
is 0-9 and A-Z.
If you extend your target alphabet
to include also certain N>0 other chars,
then you can encode an input string with less characters that it originally had
(because e.g. you can encode pairs of chars from the source alphabet with
single chars from the target alphabet).
You could attempt an LZW-like approach and look for common patterns in your input. For example - if you find that "1234" occurs often in your strings then you could encode that as "Q".
This approach cannot consistently achieve your requirements of a 16-character encoded string unless you can prove that the compression mappings you choose will always occur in the source with sufficient regularity to achieve a 16-character length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With