Jump to content

how to ENCRYPT and DECRYPT a string


nesargha

Recommended Posts

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

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 md5



example.
[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.

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.