You are here

public static function SystemStatusEncryption::encryptOpenssl in System Status 8.2

System Status: encrypt a plaintext message using openssl.

1 call to SystemStatusEncryption::encryptOpenssl()
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 51

Class

SystemStatusEncryption
Encryption logic for system_status.

Namespace

Drupal\system_status\Services

Code

public static function encryptOpenssl($plaintext) {
  $encrypt_token = \Drupal::config('system_status.settings')
    ->get('system_status_encrypt_token');
  $key = hash("SHA256", $encrypt_token, TRUE);
  $plaintext_utf8 = utf8_encode($plaintext);
  $iv = openssl_random_pseudo_bytes(16);
  $cyphertext = openssl_encrypt($plaintext_utf8, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
  return base64_encode($iv . $cyphertext);
}