public static function AES::make_iv in AES encryption 8.2
Generate an IV - initialization vector - and store it in configuration.
Parameters
bool $ignore_implementation:
3 calls to AES::make_iv()
- AES::encrypt in src/
AES.php - Encrypts a string.
- AesAdminForm::submitForm in src/
Form/ AesAdminForm.php - Form submission handler.
- aes_install in ./
aes.install - Implements hook_install().
File
- src/
AES.php, line 119
Class
Namespace
Drupal\aesCode
public static function make_iv($ignore_implementation = FALSE) {
$config = FileStorageFactory::getActive()
->read('aes.settings');
// Bail out if using phpseclib
if ($config['implementation'] == 'phpseclib' && $ignore_implementation == FALSE) {
\Drupal::logger('aes')
->warning("Called make_iv when using phpseclib. This is harmless, but shouldn't happen.");
return;
}
$randgen = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? MCRYPT_RAND : MCRYPT_DEV_URANDOM;
$cryptor = mcrypt_module_open($config['cipher'], '', MCRYPT_MODE_CBC, '');
if (!$cryptor) {
\Drupal::logger('aes')
->warning(t('Problem while calling mcrypt_module_open for cipher %cipher.'), array(
'%cipher' => $config['cipher'],
));
return;
}
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($cryptor), $randgen);
mcrypt_module_close($cryptor);
$config['mcrypt_iv'] = base64_encode($iv);
FileStorageFactory::getActive()
->write('aes.settings', $config);
}