PHP Manual
Prev |  | Next

# mcrypt_module_open

(PHP 4 >= 4.0.2)

mcrypt_module_open -- This function opens the module of the algorithm and the mode to be used

## Description

``resource mcrypt_module_open` (string algorithm, string algorithm_directory, string mode, string mode_directory)`

This function opens the module of the algorithm and the mode to be used. The name of the algorithm is specified in algorithm, eg "twofish" or is one of the MCRYPT_ciphername constants. The library is closed by calling mcrypt_module_close(), but there is no need to call that function if mcrypt_generic_end() is called. Normally it returns an encryption descriptor, or `FALSE` on error.

The `algorithm_directory` and `mode_directory` are used to locate the encryption modules. When you supply a directory name, it is used. When you set one of these to the empty string (""), the value set by the `mcrypt.algorithms_dir` or `mcrypt.modes_dir` ini-directive is used. When these are not set, the default directory are used that are compiled in into libmcrypt (usally /usr/local/lib/libmcrypt).

Example 1. mcrypt_module_open() Example
    <?php
    $td = mcrypt_module_open (MCRYPT_DES, "", MCRYPT_MODE_ECB, "/usr/lib/mcrypt-modes");
    ?>
The above example will try to open the DES cipher from the default directory and the EBC mode from the directory `/usr/lib/mcrypt-modes`.

Prev | Home | Next
mcrypt_decrypt | Up | mcrypt_module_close