Jump to content

Short String Encryption


Jarin

Recommended Posts

Hello

I am looking for a two-way encryption method that can compress/encrypt long strings into short string. IE, I have a serialized array like this:

a:102:{i:0;s:1:"1";s:6:"itemid";s:1:"1";i:1;N;s:5:"mdsum";N;i:2;s:0:"";s:8:"baseitem";s:0...etc

And I need to compress that to a string of decent length, such as one crypt() might produce. The resulting string also must be decryptable. I have tried experimenting with the mcrypt functions, but none of the resulting strings are short enough for my likes. Is there any other solution someone might be able to provide? Thanks in advance.

Jarin
Link to comment
Share on other sites

Do you need it to be cryptographically secure or just compressed? Or both?

Encrypting a string will almost always make it at least a little longer. You can use gzcompress() and gzuncompress() to make the string shorter, but your PHP installation needs to have compiled the zlib extension. You can also use gzcompress() and then crypt(), to make it shorter and secure. Just remember to undo it in the correct order.
Link to comment
Share on other sites

[!--quoteo(post=350255:date=Feb 28 2006, 10:24 AM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 28 2006, 10:24 AM) [snapback]350255[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Do you need it to be cryptographically secure or just compressed? Or both?

Encrypting a string will almost always make it at least a little longer. You can use gzcompress() and gzuncompress() to make the string shorter, but your PHP installation needs to have compiled the zlib extension. You can also use gzcompress() and then crypt(), to make it shorter and secure. Just remember to undo it in the correct order.
[/quote]

I mostly need to just be able to compress the string, no need for it to be encrypted so much as shortened.

You mentioned using crypt() after gzcompress(), however I wasn't aware that crypt() was reversible. Is this this case?
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.