Jump to content


Photo

how to ENCRYPT and DECRYPT a string


  • Please log in to reply
4 replies to this topic

#1 nesargha

nesargha
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 08 September 2006 - 07:21 AM

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




#2 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 08 September 2006 - 07:24 AM

base64_encode and base64_decode

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 September 2006 - 07:34 AM

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.
<?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;
?>

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 08 September 2006 - 09:37 AM

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.

#5 nesargha

nesargha
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 11 September 2006 - 01:26 PM

hi guys,

thank you for all the repy, i would help me i think

- nesargha




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users