Jump to content


Photo

Short String Encryption


  • Please log in to reply
2 replies to this topic

#1 Jarin

Jarin
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 February 2006 - 02:28 AM

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

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 28 February 2006 - 04:24 PM

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.

#3 Jarin

Jarin
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 02 March 2006 - 10:36 PM

[!--quoteo(post=350255:date=Feb 28 2006, 10:24 AM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 28 2006, 10:24 AM) View Post[/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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users