Search code examples
javaio

How to compress alphanumeric strings?


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.


Solution

  • 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).