nesargha Posted September 8, 2006 Share Posted September 8, 2006 hi,i want to know how can i ENCRYPT and DECRYPT a string, using php functions. i am using PHP ver 5.0, I want to encrypt the string which i will be passing between the web pages, below i have writien small code of that, which i want to achive.----------------------------------file1.php<?php$str ="xyz";$var = (encrypt the string $str and assign to $var)print "<a href='file2.php?enc=".$var." '> click here</a>";?>file2.php<?php$tmp = $_GET['enc'];$var = (decrypt $tmp and assign to $var)print "the string is $var";?>----------------------------------i know i can use Mcrypt Encryption Functions but i am not able to use this since i have to host web pages on the hosting server and my hosting server does not allow to install these functions so i have to find an alernate metod to do this.thanks in advance.nesargha Link to comment https://forums.phpfreaks.com/topic/20094-how-to-encrypt-and-decrypt-a-string/ Share on other sites More sharing options...
extrovertive Posted September 8, 2006 Share Posted September 8, 2006 base64_encode and base64_decode Link to comment https://forums.phpfreaks.com/topic/20094-how-to-encrypt-and-decrypt-a-string/#findComment-88187 Share on other sites More sharing options...
redarrow Posted September 8, 2006 Share Posted September 8, 2006 Please remeber that base_64 is a encode and decopde method but is also a flaw as it has been around for a long time and there are online database of encoded and decoded database to hack the code .Relly should use mycript or only use md5 for passwords or even better use salt and md5example.[code]<?php$message="hi there a i am redarrow hope your ok";$encoded=base64_encode($message);echo $encoded;echo "<br>";$decoded=base64_decode($encoded);echo $decoded;?>[/code]good luck. Link to comment https://forums.phpfreaks.com/topic/20094-how-to-encrypt-and-decrypt-a-string/#findComment-88192 Share on other sites More sharing options...
Jenk Posted September 8, 2006 Share Posted September 8, 2006 don't use it.. just use a session variable, database table or plain old flat file to store the info.If you are emailing someone a link to confirm registration or such, use the ID field from a database table. Link to comment https://forums.phpfreaks.com/topic/20094-how-to-encrypt-and-decrypt-a-string/#findComment-88253 Share on other sites More sharing options...
nesargha Posted September 11, 2006 Author Share Posted September 11, 2006 hi guys,thank you for all the repy, i would help me i think- nesargha Link to comment https://forums.phpfreaks.com/topic/20094-how-to-encrypt-and-decrypt-a-string/#findComment-89771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.