|
-
May 8th, 2004, 08:32 AM
#1
Thread Starter
Frenzied Member
encryption. [resolved]
I'm quite sure there is an inbuild encryption function in PHP. What is it called and how do you use it? More importantly, will the string returned ever contain the character ";"? I need that character to seperate the items in the list, if the encrypted strings contains this character it'll obviously mess things up. Is there any character it never uses?
Last edited by Acidic; May 8th, 2004 at 02:36 PM.
Have I helped you? Please Rate my posts. 
-
May 8th, 2004, 09:39 AM
#2
It depends on the cypher being used. PHP has two built in encrpytion functions : md5() and crypt().
MD5 uses the Message digest Algorithm and crypt uses DES. I'm not sure the exact output of these however a glance at their RFC's will soon tell you. Those fnctions are only one way encryption however. If you want two way encryption you'll need to use the mcrypt extension.
-
May 8th, 2004, 11:44 AM
#3
Thread Starter
Frenzied Member
OK, I've found:
http://www.php.net/manual/en/functio...pt-generic.php
but when I run it it says:
Fatal error: Call to undefined function: mcrypt_module_open() in c:\documents and settings\sid karunaratne\my documents\acidic library - php\mailing list\send_mail.php on line 13
What's going on?
Have I helped you? Please Rate my posts. 
-
May 8th, 2004, 12:02 PM
#4
It requires the mcrypt extension. To enable it you can downloaded the library from here - its called libmcrypt.dll and place it in a system path directory. Then edit your php.ini and add the following line in the extensions section (it may already be there - in which case you just need to un comment it):
extension=php_mcrypt.dll
-
May 8th, 2004, 12:34 PM
#5
Thread Starter
Frenzied Member
OK, I've done that, but now it won't decrypt it. I copy pasted the example from the link above exactly. Here it is anyway:
PHP Code:
<?
$key = "this is a secret key";
$input = "Let us meet at 9 o'clock at the secret place.";
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$encrypted_data = mcrypt_generic($td, $input);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
echo "Encrypt: ".$encrypted_data;
echo "<br><br>";
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
mcrypt_generic_init($td, $key, $iv);
$decrypted_data = mdecrypt_generic($td, $encrypted_data);
echo "Decrypt: ".$decrypted_data;
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
?>
I seriously doubt that's where the error is though. I don't think it's a .dll file missing either as it doesn't give me any errors. The decrypted string is just the same as the encrypted string.
Have I helped you? Please Rate my posts. 
-
May 8th, 2004, 01:04 PM
#6
I'm not too clued up on encryption and I've never used the mcrypt functions in PHP. What I do know is that it can be very complex and probably requires some background reading before you dive in.
I found a tutorial which looks quite in depth and comprehensive:
http://hotwired.lycos.com/webmonkey/...tutorial1.html
-
May 8th, 2004, 01:13 PM
#7
Thread Starter
Frenzied Member
OK, i'll have a read. But are there also simpler methods?
Have I helped you? Please Rate my posts. 
-
May 8th, 2004, 01:23 PM
#8
I don't think there is. If you are trying to encrypt the data for transfer over the web then it might be easier to set up SSL on your server.
-
May 8th, 2004, 02:36 PM
#9
Thread Starter
Frenzied Member
It's not for that, but I've found I can use base64_encode(str) and base64_decode(str).
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|