You are here

public function MCrypt::getIv in DRD Agent 8.3

Same name and namespace in other branches
  1. 4.0.x src/Crypt/Method/MCrypt.php \Drupal\drd_agent\Crypt\Method\MCrypt::getIv()

Get an initialiation vector.

Return value

string The IV.

Overrides BaseMethodInterface::getIv

1 call to MCrypt::getIv()
MCrypt::encrypt in src/Crypt/Method/MCrypt.php
Encrypt and encode any list of arguments.

File

src/Crypt/Method/MCrypt.php, line 76

Class

MCrypt
Provides MCrypt encryption functionality.

Namespace

Drupal\drd_agent\Crypt\Method

Code

public function getIv() : string {
  if (empty($this->iv)) {
    $nonceSize = mcrypt_get_iv_size($this->cipher, $this->mode);

    /** @noinspection CryptographicallySecureRandomnessInspection */
    $this->iv = mcrypt_create_iv($nonceSize, MCRYPT_DEV_URANDOM);
  }
  return $this->iv;
}