Page 1 of 1

encrypting

Posted: Sun Jun 15, 2003 11:22 pm
by Cruzado_Mainfrm
i was reading through the php.net manual and i tryied this code:

Code: Select all

<?php
$key = "this is a secret key"; 
$input = "Let us meet at 9 o'clock at the secret place."; 

$encrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT); 
?>
but i get this as result:
Fatal error: Call to undefined function: mcrypt_ecb() in C:\modtestingforum\test\index.php on line 6
PHP Fatal error: Call to undefined function: mcrypt_ecb() in C:\modtestingforum\test\index.php on line 6

i don't know how to implement this to my php or what do i have to do, do i need the mcrypt libraries and put them in somewhere so they can work? thnx in advance

Posted: Mon Jun 16, 2003 6:47 am
by cactus
You are correct, you will need to get the lib's for your OS (Win32 I believe) and install them, configure the php.ini and restart the server.

http://ftp.proventum.net/pub/php/win32/misc/mcrypt/
http://mcrypt.hellug.gr/lib/index.html
http://uk.php.net/mcrypt_

Regards,

i think i've installed it ok but...

Posted: Mon Jun 16, 2003 8:27 am
by Cruzado_Mainfrm
i think i've installed it ok but i get this warning(i'm debugging):
Warning: mcrypt_ecb(): Attempt to use an empty IV, which is NOT recommend in C:\modtestingforum\test\index.php on line 6

without changing the e~all & e~notice thing

Posted: Mon Jun 16, 2003 8:30 am
by Stoker
just a warning; Such encryption where the same key is used for decrypt should never be used for sensitive information in a shared hosting environment (e.g. CC-numbers), and should be used with caution in any other (dedicated/protected) environment.. The data is very safe by itself, but your key is the hard part to protect if used in any type of automated environment.

Posted: Mon Jun 16, 2003 8:32 am
by Cruzado_Mainfrm
nah it was just a warning, i took off the e~warning and e~notice :D

Posted: Mon Jun 16, 2003 8:33 am
by cactus
You need to either specify an IV or create one using the mcrypt_create_iv() method.

Regards,

Posted: Mon Jun 16, 2003 9:27 am
by Cruzado_Mainfrm
well i'm learning php right now, i can say i know the basics now lol!
by the way, that was just an example in the php manual that i was trying to do :D. In the other hand, how do i specify an IV and what is an IV :D

Posted: Mon Jun 16, 2003 9:36 am
by nielsene
An IV=Initialization Vector. You create one using the mcrypt_create_iv function cactus referenced above

Posted: Mon Jun 16, 2003 9:38 am
by Cruzado_Mainfrm
so i just write mcrypt_create_iv() and it does the work for me? or do i have specify any variables in the function?

Posted: Mon Jun 16, 2003 9:44 am
by nielsene
Read the manual. It has an example. You'll probably need to call mcrypt_get_iv_size first as well with your cypher settings.

Posted: Mon Jun 16, 2003 9:45 am
by Cruzado_Mainfrm
i'll try that :D i'm gonna read the ENTIRE manual :D, cuz i don't wanna miss anything thnx all of u