You are here: Trouble decrypting data « All PHP « IT news, forums, messages
Trouble decrypting data

Posted by laredotornado on 12/12/06 18:05

Hi, I'm using PHP 4.4.4. I have two functions, and my goal is to print
out "encryption/decrpytion successful".

$str = "hello";
$encryptedStr = encryptData($str);
$decryptedStr = decryptStr($encryptedStr);
if ($str == $decryptedStr) {
print "encryption/decryption successful.";
}

Unfortunately, this is not happening. These are my functions ...

function encryptData($p_str)
{
$iv = ENCRYPTION_VECTOR;
$enc = mcrypt_encrypt(MCRYPT_XTEA,
ENCRYPTION_KEY, $p_str, MCRYPT_MODE_ECB, $iv);
return $enc;
} // encryptstring

function decryptData($p_str)
{
$iv = ENCRYPTION_VECTOR;
$crypttext = mcrypt_decrypt(MCRYPT_XTEA,
ENCRYPTION_KEY, $p_str, MCRYPT_MODE_ECB, $iv);
return $crypttext;
} // decryptData

ENCRYPTION_VECTOR is a hard coded string I created with this call

$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA,
MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);

I cut and pasted the value of "$iv" into my ENCRYPTION_VECTOR constant.
Any idea why my functions are failing?

Thanks, - Dave

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация