Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

//loop over each one
foreach($algorithm as $value)
{
print("\n");
print("".
mcrypt_get_cipher_name($value). "");
print("".
mcrypt_get_block_size($value). "");
print("". mcrypt_get_key_size($value)


. "");
print("\n");
}


print("\n");
?>


integer mcrypt_get_key_size(integer algorithm)


Use mcrypt_get_key_size to find the key size for a given encryption algorithm.


Use one of the constants listed in Table 9.8. See mcrypt_get_cipher_name for
an example of use.


mcrypt_ofb(integer algorithm, string key, string data, integer
mode, string initialization_vector)


The mcrypt_ofb function encrypts a string using output feedback. This method is
another method suited to stream ciphers. The algorithm argument is one of the
constants listed in Table 9.8. The mode argument can be either MCRYPT_DECRYPT or
MCRYPT_ENCRYPT. An initialization vector is required. You must use the same one to
decrypt.


<?


//set up test data
$message = "This message is sensitive.";
$key = "secret";
$iv = mcrypt_create_iv(
mcrypt_get_block_size(MCRYPT_BLOWFISH_128),
MCRYPT_DEV_RANDOM);


//encrypt message

Free download pdf