when linked against libmcrypt 2.2.x string mcrypt_cfb string cipher, string key, string data, int mode [, string init_vector] when linked against libmcrypt 2.4.x Description The mcrypt
Trang 1(when linked against libmcrypt 2.2.x)
string mcrypt_cfb (string cipher, string key, string data, int mode [, string init_vector])
(when linked against libmcrypt 2.4.x)
Description
The mcrypt_cfb() function will encrypt or decrypt the data with cipher and key in
CFB cipher mode cipher is passed in the form of MCRYPT_ name where name is the
name of the cipher used The determination of encrypting or decrypting the data is done by looking at the mode , which can be MCRYPT_ENCRYPT or MCRYPT_DECRYPT The
optional init_vector parameter is the initialization vector
mcrypt_create_iv()
Syntax
string mcrypt_create_iv(int size, int source)
Description
The mcrypt_create_iv() function creates an initialization vector of size and of
source The source can be one of the items in Table 11.20
Table 11.20 Possible source Values
MCRYPT_DEV_RANDOM Read data from /dev/random
MCRYPT_DEV_URANDOM Read data from /dev/urandom
MCRYPT_RAND System random number generator Make sure to call srand()
before to initialize the random number generator
mcrypt_ecb()
Syntax
string mcrypt_ecb(int cipher, string key, string data, int mode)
(when linked against libmcrypt 2.2.x)
string mcrypt_ecb(string cipher, string key, string data, int mode
[, string init_vector])
Trang 2(when linked against libmcrypt 2.4.x)
Description
The mcrypt_ecb() function will encrypt or decrypt the data with cipher and key in
ECB cipher mode cipher is passed in the form of MCRYPT_ name where name is the
name of the cipher used The determination of encrypting or decrypting the data is done by looking at the mode , which can be MCRYPT_ENCRYPT or MCRYPT_DECRYPT The optional init_vector parameter is the initialization vector
mcrypt_enc_get_algorithms_name()
Syntax
int mcrypt_enc_get_algorithms_name(resource encrypt_descriptor)
Description
The mcrypt_enc_get_algorithms_name() function, which was added in PHP 4.0.2, returns the name of the currently opened algorithm
mcrypt_enc_get_block_size()
Syntax
int mcrypt_enc_get_block_size(resource encrypt_descriptor)
Description
The mcrypt_enc_get_block_size() function, which was added in PHP 4.0.2, returns the block size, in bytes, of the algorithm specified by encrypt_descriptor
mcrypt_enc_get_iv_size()
Syntax
int mcrypt_enc_get_iv_size(resource encrypt_descriptor)
Description
Trang 3The mcrypt_enc_get_iv_size() function, which was added in PHP 4.0.2, returns the size, in bytes, of the initialization vector of the algorithm specified by
encrypt_descriptor This should work in CBC, CFB, and OFB modes, and in some
algorithms it also works in stream mode If the initialization vector is ignored in the algorithm, the function returns 0
mcrypt_enc_get_key_size()
Syntax
int mcrypt_enc_get_key_size(resource encrypt_descriptor)
Description
The mcrypt_enc_get_key_size() function, which was added in PHP 4.0.2, returns the maximum key size, in bytes, of the algorithm referenced by
encrypt_descriptor
mcrypt_enc_get_modes_name()
Syntax
int mcrypt_enc_get_modes_name(resource encrypt_descriptor)
Description
The mcrypt_enc_get_modes_name() function, which was added in PHP 4.0.2, returns the name of the opened encrypt_descriptor
mcrypt_enc_get_supported_key_sizes()
Syntax
int mcrypt_enc_get_supported_key_sizes(resource encrypt_descriptor)
Description
The mcrypt_enc_get_supported_key_sizes() function, which was added in PHP 4.0.2, returns an array with the supported key sizes of encrypt_descriptor
mcrypt_enc_is_block_algorithm()
Trang 4Syntax
int mcrypt_enc_is_block_algorithm(resource encrypt_descriptor)
Description
The mcrypt_enc_is_block_algorithm() function, which was added in PHP 4.0.2, returns 1 if the algorithm specified by encrypt_descriptor is a block algorithm If it
is a stream algorithm, 0 is returned
mcrypt_enc_is_block_algorithm_mode()
Syntax
int mcrypt_enc_is_block_algorithm_mode(resource encrypt_descriptor)
Description
The mcrypt_enc_is_block_algorithm_mode() function, which was added in PHP 4.0.2, returns 1 if the mode attached to encrypt_descriptor is for use with block algorithms, such as CBC, CFB, and OFB Otherwise, the function returns 0 for stream
mcrypt_enc_is_block_mode()
Syntax
int mcrypt_enc_is_block_mode(resource encrypt_descriptor)
Description
The mcrypt_enc_is_block_mode() function, which was added in PHP 4.0.2, returns
1 if the mode attached to encrypt_descriptor outputs blocks of bytes, as with CBC,
CFB, and OFB Otherwise, the function returns 0 for non-block byte output
mcrypt_enc_self_test()
Syntax
int mcrypt_enc_self_test(resource encrypt_descriptor)
Trang 5Description
The mcrypt_enc_self_test() function, which was added in PHP 4.0.2, runs a self test on the algorithm specified by encrypt_descriptor It returns 1 if the test is
successful or 0 otherwise
mcrypt_encrypt()
Syntax
string mcrypt_encrypt(string cipher, string key, string data, string
mode
[, string init_vector])
Description
The mcrypt_encrypt() function, which was added in PHP 4.0.2, encrypts the data with cipher and key in the specified cipher mode cipher is passed in the form of MCRYPT_ name where name is the name of the cipher used The mode is one of the
MCRYPT_MODE_ name constants (ECB, CBC, CFB, OFB, NOFB, or STREAM) and it determines the mode of the encryption The optional init_vector parameter is the
initialization vector for CBC, CFB, OFB modes, and in some algorithms, for STREAM mode
Note
If the data is not of the appropriate block size, it is padded with \ 0 Additionally, if the intt_vector parameter is not passed, it is assumed to
be all \ 0
mcrypt_decrypt()
Syntax
string mcrypt_decrypt(string cipher, string key, string data, string
mode
[, string init_vector])
Description