TestEncryptionMethod.php in Encrypt 8.3
File
tests/modules/encrypt_test/src/Plugin/EncryptionMethod/TestEncryptionMethod.php
View source
<?php
namespace Drupal\encrypt_test\Plugin\EncryptionMethod;
use Drupal\encrypt\EncryptionMethodInterface;
use Drupal\encrypt\Plugin\EncryptionMethod\EncryptionMethodBase;
class TestEncryptionMethod extends EncryptionMethodBase implements EncryptionMethodInterface {
public function checkDependencies($text = NULL, $key = NULL) {
$errors = [];
return $errors;
}
public function encrypt($text, $key, $options = []) {
return str_rot13($key . $text);
}
public function decrypt($text, $key, $options = []) {
$decoded = str_rot13($text);
if (substr($decoded, 0, strlen($key)) == $key) {
return substr($decoded, strlen($key));
}
else {
return "invalid key";
}
}
}