PHP.nl

mcrypt_create_iv

mcrypt_create_iv

Creates an initialization vector (IV) from a random source

Waarschuwing: > random_bytes

string **mcrypt_create_iv** int $size int $source

Creates an initialization vector (IV) from a random source.

The IV is only meant to give an alternative seed to the encryption routines. This IV does not need to be secret at all, though it can be desirable. You even can send it along with your ciphertext without losing security.

sizeThe size of the IV.

source The source of the IV. The source can be (system random number generator), (read data from ) and (read data from ). Prior to 5.3.0, was the only one supported on Windows. MCRYPT_RAND``MCRYPT_DEV_RANDOM``MCRYPT_DEV_URANDOM``MCRYPT_RAND

  Note that the default value of this parameter was
   prior to PHP 5.6.0.
 `MCRYPT_DEV_RANDOM`

Opmerking: > Note that may block until more entropy is available. MCRYPT_DEV_RANDOM

Returns the initialization vector, or false on error.

Voorbeeld: Example

<?php
    $size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB);
    $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
?>

url.mcrypt.ivurl.mcrypt.bcmrandom_bytes