Jarin Posted February 28, 2006 Share Posted February 28, 2006 HelloI 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...etcAnd 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 Quote Link to comment Share on other sites More sharing options...
wickning1 Posted February 28, 2006 Share Posted February 28, 2006 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 Link to comment Share on other sites More sharing options...
Jarin Posted March 2, 2006 Author Share Posted March 2, 2006 [!--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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.