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
https://forums.phpfreaks.com/topic/3717-short-string-encryption/
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
https://forums.phpfreaks.com/topic/3717-short-string-encryption/#findComment-13036
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
https://forums.phpfreaks.com/topic/3717-short-string-encryption/#findComment-13718
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.