I have a ~30 length byte arrays.
I am looking for a way to pass this data to several users with the following requirements:
1. It has to be short.. about 16 chars at max.
2. Only printable chars are acceptable (only digits or only letters will be even better).
3. It must to be a printable output (save to file or using socket is not what I want).
4. (Thanks to Tudor) I want to be able to decode it back to the original array
The arrays contain quite random data which makes this problem very difficult to crack.
I have tried many compression methods but with no luck so far.
After the compression I will probably encode the data to 64 base to make the output as short as possible (unless there is a better way to it)
The project is basically in java but if there is a solution in other language I would love to here about it.
thanks in advance
Truly random data will use as many bytes to encode as decode (if not more).
When you compress data, you exploit inherent non-random structure in the data to make something which is more random but smaller. This is why it is very hard to compress already compressed data.
In your case you appear to want to encode 30 * 8 bits or 240 bits into 16 * 6 bits or 96 bits. This means your data must not be very random to compress it at least 2.5 times. Compressing it this much every time would be very hard to do and you always have the possibility your compressed string will be larger than when you started. All you can do is to make this unlikely.
Unless your data does not have inherent compressibility you cannot use lossless compression (which is reversible) If lossy compression is an option, you still have to make assumptions about what information can be lost.
If you need to match a code with some information what you can do is to generate a random unique code and use this a key to some database. The benefit of using this approach is that the key can be as short as you like, provided you will never need more unique keys than you will generate, and you can associate as much information with the key as you like as well.
I believe this is your best option given the constraints you have.
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