Studying mcrypt
| From: | Andre Polykanine | Date: | Wed, 03 Aug 2011 16:40:20 +0000 |
| Subject: | Studying mcrypt | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-314308@lists.php.net to get a copy of this message | ||
Hello Php,
It's my first time I use mcrypt.
I've done everything like it's written in the php manuals, here is the code:
<?php
$d=mcrypt_module_open("rijndael-256", "", "ofb", "");
$iv=mcrypt_create_iv(mcrypt_enc_get_iv_size($d), MCRYPT_DEV_RANDOM);
$ks=mcrypt_enc_get_key_size($d);
$key=substr(md5("Secret key"), 0, $ks);
mcrypt_generic_init($d, $key, $iv);
$cpass=mcrypt_generic($d, $_POST['opass']);
mcrypt_generic_deinit($d);
mcrypt_module_close($d);
?>
And here's what I get:
Original password: asdfasdfasdf
Encrypted password: Q�j�����*
Question: Is it normal to have such strange characters in the encrypted string?
I'm hosted at http://godaddy.com/, shared hosting, if it
does matter.
Thanks!
--
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion