You are here

public function ConfigTestEncryptionMethod::encrypt in Encrypt 8.3

Encrypt text.

Parameters

string $text: The text to be encrypted.

string $key: The key to encrypt the text with.

Return value

string The encrypted text

Throws

\Drupal\encrypt\Exception\EncryptException Thrown when encryption fails.

Overrides EncryptionMethodInterface::encrypt

File

tests/modules/encrypt_test/src/Plugin/EncryptionMethod/ConfigTestEncryptionMethod.php, line 33

Class

ConfigTestEncryptionMethod
ConfigTestEncryptionMethod testing class.

Namespace

Drupal\encrypt_test\Plugin\EncryptionMethod

Code

public function encrypt($text, $key, $options = []) {
  $prefix = $key . $this
    ->getConfiguration()['mode'];
  return str_rot13($prefix . $text);
}