Click to See Complete Forum and Search --> : [RESOLVED] Need help with a small mcrypt project.


Dumpduck
01-25-2008, 07:11 PM
Hello,
I'm doing a small project, where I wan't to demonstrate some basic private key encryption. I have very little knowledge on PHP and HTML in general, but wouldn't let that stop me. I was recommended to try mcrypt, which I did. What I wanna do is create two webpages. One called encrypt.php, the other decrypt.php.
The first page should contain two textarea-boxes, one for typing a text, the other for a password (it should print/echo the encrypted msg below the boxes). The other should contain two boxes as well, one where you could type in the encrypted data, and ofc the other to enter the key and decrypt it (if the key is correct).

I've managed to create the encrypt page?

<?php
$key = $_POST["passkey"];
$input = $_POST["text"];

$encrypted_data = mcrypt_cbc (MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT);
?>

<form method="post" action="">
<textarea name="text" cols="50" rows="10">
Enter your text here
</textarea><br>
<textarea name="passkey" cols="20" rows="1">
key
</textarea><br>
<input type="submit" value="Encrypt!" />
</form>

<?php echo $encrypted_data; ?>
(http://dumpduck.com/encrypt.php)

But now I'm somewhat stuck. How should the second page look like, so I can decrypt the data again?

Thanks in advance.

skyrider01
01-27-2008, 12:22 AM
Seems all you need to do is it to change the MCRYPT_ENCRYPT to MCRYPT_DECRYPT and use similar approach to what you already have done.

However, according to the php documentation (http://au2.php.net/mcrypt_cbc) this function should not be used any longer