SCook Posted June 27, 2007 Share Posted June 27, 2007 Hi all, I would like to encrypt a query string, then decrypt it later. What is the quickest way to do this? A quick example coding would be very helpful. Link to comment https://forums.phpfreaks.com/topic/57355-encryptdecrypt-query-string/ Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 http://us.php.net/manual/en/ref.mcrypt.php Link to comment https://forums.phpfreaks.com/topic/57355-encryptdecrypt-query-string/#findComment-283620 Share on other sites More sharing options...
JasonLewis Posted June 27, 2007 Share Posted June 27, 2007 also have a gander a base64. http://au.php.net/manual/en/function.base64-encode.php http://au.php.net/manual/en/function.base64-decode.php its probably not very good for query strings though. Link to comment https://forums.phpfreaks.com/topic/57355-encryptdecrypt-query-string/#findComment-283796 Share on other sites More sharing options...
SCook Posted June 27, 2007 Author Share Posted June 27, 2007 That helps, and I've looked into mcrypt, but I was hoping for an actual example code I could look at. Sometimes the manual is a little vague. Can anyone paste some quick code to show me the proceedure? Thanks. Link to comment https://forums.phpfreaks.com/topic/57355-encryptdecrypt-query-string/#findComment-284106 Share on other sites More sharing options...
per1os Posted June 27, 2007 Share Posted June 27, 2007 kooktroop at gmail dot com 09-Jul-2004 06:13 Following on from the mcrypt_encrypt() example: <?php $text = "boggles the inivisble monkey will rule the world"; $key = "This is a very secret key"; $iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); echo strlen($text) . "<br>"; $enc = mcrypt_encrypt(MCRYPT_XTEA, $key, $text, MCRYPT_MODE_ECB, $iv); echo strlen($enc) . "<br>"; $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $key = "This is a very secret key"; $text = "Meet me at 11 o'clock behind the monument."; echo strlen($text) . "<br>"; $crypttext = mcrypt_decrypt(MCRYPT_XTEA, $key, $enc, MCRYPT_MODE_ECB, $iv); echo "$crypttext<br>"; ?> Found at http://us.php.net/manual/en/function.mcrypt-decrypt.php#43938 Link to comment https://forums.phpfreaks.com/topic/57355-encryptdecrypt-query-string/#findComment-284114 Share on other sites More sharing options...
SCook Posted June 27, 2007 Author Share Posted June 27, 2007 Okay, cool. And to descrypt, I just need to use mcrypt_descrypt and ente rthe same values as I used to encrypt, right? Link to comment https://forums.phpfreaks.com/topic/57355-encryptdecrypt-query-string/#findComment-284148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.