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

(singke) #1

//encrypt message
$code = mcrypt_cbc(MCRYPT_BLOWFISH_128, $key,
$message, MCRYPT_ENCRYPT);


//pring decrypted message
print(mcrypt_cbc(MCRYPT_BLOWFISH_128, $key, $code,
MCRYPT_DECRYPT));
?>


integer mcrypt_get_block_size(integer algorithm)


Use mcrypt_get_blocksize to find the block 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.


string mcrypt_get_cipher_name(integer algorithm)


Use mcrypt_get_cipher_name to get the name of an encryption algorithm. Use


one of the constants listed in Table 9.8.


<?


//create array of encryption algorithms
$algorithm = array(
3DES, 3WAY, BLOWFISH_128, BLOWFISH_192,
BLOWFISH_256,
BLOWFISH_448, CAST_128, CAST_256, DES,
GOST, IDEA, LOKI97,
RC2_1024, RC2_128, RC2_256, RC4, RC6_128,
RC6_192, RC6_256,
RIJNDAEL_128, RIJNDAEL_192, RIJNDAEL_256,
SAFERPLUS,
SAFER_128, SAFER_64, SERPENT_128,
SERPENT_192, SERPENT_256,
TWOFISH_128, TWOFISH_192, TWOFISH_256,
XTEA);


print("<TABLE BORDER=\"1\">\n");


print("\n");
print("Name\n");
print("Block Size\n");
print("Key Size\n");
print("\n");

Free download pdf