Reputation: 187
Is there way to compress an alphanumeric string with length = 128 * 2 + 1 to shortest unique representation?
Upvotes: 2
Views: 989
Reputation: 5535
I was wondering if you are only concerned about "shortest unique representation" and you no longer need to get the original string back, you can always apply and compute a hash.
It could be any of the SHA's or MD5 or some other one. It is generally guaranteed to be unique but is one way and you cannot get the original data back.
That is how passwords are stored and verified all over the internet.
Upvotes: 1
Reputation: 399919
Of course, but the compression will depend on the available entropy in the string, as always.
I would look into Huffman coding, as a starting point. It's fairly easy to implement, and if you control both ends of the compress/decompress chain, you might get away with a well-chosen hard-coded coding, which saves even more space.
Upvotes: 7