You are here

public function Kitchen::decrypt in Bakery Single Sign-On System 8.2

Decryption handler.

Parameters

string $text: The data to be decrypted.

Return value

string Decrypted text.

1 call to Kitchen::decrypt()
Kitchen::tasteData in src/Kitchen.php
Validate signature and decrypt data.

File

src/Kitchen.php, line 332

Class

Kitchen

Namespace

Drupal\bakery

Code

public function decrypt(string $text) : string {
  $td = phpseclib_mcrypt_module_open('rijndael-128', '', 'ecb', '');
  $iv = phpseclib_mcrypt_create_iv(phpseclib_mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
  $key = substr($this->config
    ->get('bakery_key'), 0, phpseclib_mcrypt_enc_get_key_size($td));
  phpseclib_mcrypt_generic_init($td, $key, $iv);
  $data = phpseclib_mdecrypt_generic($td, $text);
  phpseclib_mcrypt_generic_deinit($td);
  phpseclib_mcrypt_module_close($td);
  return $data;
}