/** * {@inheritdoc} */ function decrypt($text) { // Get settings. $settings = $this->config->get('encrypt.settings'); // Load the key. $key = $this->key->getKey($settings->get('encryption_key')); // Load the encryption method. $enc_method = $this->manager->createInstance($settings->get('encryption_method')); // Return the encrypted string. return $enc_method->decrypt($text, $key->getKeyValue()); }
/** * Test load by key id. * * @group key */ public function testGetKey() { $key = $this->keyManager->getKey($this->key_id); $this->assertInstanceOf('\\Drupal\\key\\Entity\\Key', $key); $this->assertEquals($this->key->get('key_id'), $key->get('key_id')); }