2008. 01. 25, péntek keltezéssel 00.20-kor Jochem Maas ezt írta:
> someone asked about checksum values in another thread, I believe
> he got his answer no thanks to me. but whilst I was trying to help
> I got stuck playing with pack/unpack.
>
> so now I have the broadbrush question of what would one use
> pack/unpack for? can anyone point at some realworld examples/code that
> might help me broaden my horizons?
>
I have used pack in my password decrypt function:
function encode_pwd($text) {
$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,
md5('secret key goes here'),
$text,
MCRYPT_MODE_ECB,
$iv
));
}
function decode_pwd($encrypted_text) {
$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,
md5('secret key goes here'),
pack("H*", $encrypted_text),
MCRYPT_MODE_ECB,
$iv
));
}
greets
Zoltán Németh
> rds,
> jochem
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php