Compress short fixed length string (52 characters) down to less than 40.
-
hello, I tried googling for an algorithm to compress/encrypt a shor fixed size string from 52 characters down to 40 but can't seem to find any. Target strings are random alphanumeric [A-Z0-9] e.g "M5KS07VHN2X42JCY1PFHE1ZZGI2XUBDFAKQBEPFB7CH4SECXHJXL" I have tried huffman and smaz (https://github.com/antirez/smaz") and both inflated to size of the original string. Does anyone know a good algorith for such purpose? Thanks,
-
hello, I tried googling for an algorithm to compress/encrypt a shor fixed size string from 52 characters down to 40 but can't seem to find any. Target strings are random alphanumeric [A-Z0-9] e.g "M5KS07VHN2X42JCY1PFHE1ZZGI2XUBDFAKQBEPFB7CH4SECXHJXL" I have tried huffman and smaz (https://github.com/antirez/smaz") and both inflated to size of the original string. Does anyone know a good algorith for such purpose? Thanks,
The characters in the given range are hex 0x30 to 0x5A. When subtracting 0x30, you will get a range from 0 to 0x2A which can be represented by 6 bits (there is also space for handling null when subtracting 0x29). The range can be additionally reduced by subtracting different values for digits and letters. When using 6 bits, you can compress the data to 52 / 8 * 6 = 39 byte. All you have to do is subtracting the offset from each character and shifting the 6 bits into your output buffer.
-
hello, I tried googling for an algorithm to compress/encrypt a shor fixed size string from 52 characters down to 40 but can't seem to find any. Target strings are random alphanumeric [A-Z0-9] e.g "M5KS07VHN2X42JCY1PFHE1ZZGI2XUBDFAKQBEPFB7CH4SECXHJXL" I have tried huffman and smaz (https://github.com/antirez/smaz") and both inflated to size of the original string. Does anyone know a good algorith for such purpose? Thanks,
Try LZ4 (http://code.google.com/p/lz4/[^]). It's great, though I don't know how much it would help you since that's a very short string and not very compressible as is.
-
hello, I tried googling for an algorithm to compress/encrypt a shor fixed size string from 52 characters down to 40 but can't seem to find any. Target strings are random alphanumeric [A-Z0-9] e.g "M5KS07VHN2X42JCY1PFHE1ZZGI2XUBDFAKQBEPFB7CH4SECXHJXL" I have tried huffman and smaz (https://github.com/antirez/smaz") and both inflated to size of the original string. Does anyone know a good algorith for such purpose? Thanks,
If your input characters are all 0-127 ASCII, you could store 9 characters in 8 bytes. It only amounts to about a 12.5% savings (which does not meet your requirement), but it's easy enough to code up.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
hello, I tried googling for an algorithm to compress/encrypt a shor fixed size string from 52 characters down to 40 but can't seem to find any. Target strings are random alphanumeric [A-Z0-9] e.g "M5KS07VHN2X42JCY1PFHE1ZZGI2XUBDFAKQBEPFB7CH4SECXHJXL" I have tried huffman and smaz (https://github.com/antirez/smaz") and both inflated to size of the original string. Does anyone know a good algorith for such purpose? Thanks,
-
yes. the answer is base64. (since all characters are alphanumeric, they can be encoded in 6 bits instead of 8) btw, thank you all for your answers.