Jump to content

Simple text compression, How can show it after done?


oni-kun

Recommended Posts

I'm writing my own encoding program basically, and even though it has some more things in it, basically the calculated/base64 encoded string is 50% larger than my original. This is alright, but i'd like the string to be smaller. I've used gzdeflate/gzcompress but it outputs bytes? so it can't be displayed by echoing it.

 

Is there a possible way to compress the size of the text, and display it in a showable fasion? Maybe there's a way to show the actual bytes of the gzcompressed stream (bin2hex? somehow?) as long as it's shorter.. If you could help i'd be so incredibly greatful!

 

<?php
$compressed = gzdeflate('mtfPJtAkE0UVtWQMcP65HYIROavx5t4TD+o7YYZ8C8ICQ+y', 9);
echo $compressed; //As bytes? some sort of string ?
?>

 

Is pretty much what I use, I just don't know how to make it so it can copy, and not be as big as the base64 string..

Link to comment
Share on other sites

1) Why are you trying to make your own compression algorithm?

2) Why do you want to show the compressed data to the user in a viewable format? Compressed data is meaningless to a human.

3) Why do you think showing the gz compressed data in binary form (I assume you by this mean displaying each character's ordinal equivalent in the ASCII charset as base 2, because all data in a computer is binary)? A byte has 8 bits, so if you do that you can multiply the size with 8.

Link to comment
Share on other sites

1) Why are you trying to make your own compression algorithm?

2) Why do you want to show the compressed data to the user in a viewable format? Compressed data is meaningless to a human.

3) Why do you think showing the gz compressed data in binary form (I assume you by this mean displaying each character's ordinal equivalent in the ASCII charset as base 2, because all data in a computer is binary)? A byte has 8 bits, so if you do that you can multiply the size with 8.

 

I'm actually making an encryption as a project, I shift the string with a key and encode it in base64, apply salted blowfish and ECB Rijndael (with mcrypt() ).

 

The result length is well over the length of the original string. Since my encryption is 'very strong' I'd like it to be shorter. Text is compressed normally like 1:25? And has a dictionary for inflation (or something) when you compress it using PKZIP or whatnot.. There has to be a way of displaying that end result, and letting me use it!

 

Bin2Hex() shortens the stream, when it's compressed (no matter what 'level' I use of compression it's the same length), by about 20%.. Maybe that's just the way I have to do, not sure where to turn.

 

Original: Free the prisoners
Encrypted: --IEOt1L1RPsJiFWdTwxHv9iCztuZXpHH0dmoZf9Qqs3M=--
gzcompress/Bin2Hex: 732b4a4d5528c948552828ca2ccecf4b2d2a0600

 

I'm probably over my head!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.