encrypting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

encrypting

Post 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
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post 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,
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

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

Post 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
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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.
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

nah it was just a warning, i took off the e~warning and e~notice :D
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

You need to either specify an IV or create one using the mcrypt_create_iv() method.

Regards,
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post 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
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

An IV=Initialization Vector. You create one using the mcrypt_create_iv function cactus referenced above
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post 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?
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post 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.
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post 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
Post Reply