that time, the password is asked for, encrypted, and compared to the previously encrypted
password.
Depending on your operating system, alternatives to DES encryption may be available.
The salt argument is used to determine which algorithm to use. A two-character salt is
used for standard DES encryption. A nine-character salt specifies extended DES. A
twelve-character salt specifies MD5 encryption. And a sixteen-character salt specifies the
blowfish algorithm.
When PHP is compiled, available algorithms are incorporated. The following constants
will hold TRUE or FALSE values you can use to determine the availability of the four
algorithms: CRYPT_STD_DES, CRYPT_EXT_DES, CRYPT_MD5, CRYPT_BLOWFISH.
<?
$password = "secret";
if(CRYPT_MD5)
{
$salt = "leonatkinson";
print("Using MD5: ");
}
else
{
$salt = "cp";
print("Using Standard DES: ");
}
print(crypt($password, $salt));
?>
string mcrypt_create_iv(integer size, integer source)
Use mcrypt_create_iv to create an initialization vector. The size should match the
encryption algorithm and should be set using mcrypt_get_block_size. The source
argument can be one of three constants. MCRYPT_DEV_RANDOM uses random numbers
from /dev/random. MCRYPT_DEV_URANDOM uses random numbers from
/dev/urandom. MCRYPT_RAND uses random numbers from the rand function,
which means you ought to seed it first with srand.
string mcrypt_cbc(integer algorithm, string key, string data,
integer mode, string initialization_vector)