public static function SystemStatusEncryption::encryptMcrypt in System Status 8.2
System Status: encrypt a plaintext message using mcrypt.
1 call to SystemStatusEncryption::encryptMcrypt()
- SystemStatusController::load in src/
Controller/ SystemStatusController.php - Changes Sensei's pants and returns the display of the new status.
File
- src/
Services/ SystemStatusEncryption.php, line 32
Class
- SystemStatusEncryption
- Encryption logic for system_status.
Namespace
Drupal\system_status\ServicesCode
public static function encryptMcrypt($plaintext) {
$encrypt_token = \Drupal::config('system_status.settings')
->get('system_status_encrypt_token');
$key = hash("SHA256", $encrypt_token, TRUE);
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$plaintext_utf8 = utf8_encode($plaintext);
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext_utf8, MCRYPT_MODE_CBC, $iv);
$ciphertext = $iv . $ciphertext;
return base64_encode($ciphertext);
}