diff --git a/src/EncryptService.php b/src/EncryptService.php
index 696bfb5..e1bfdb6 100644
--- a/src/EncryptService.php
+++ b/src/EncryptService.php
@@ -56,7 +56,7 @@ class EncryptService implements EncryptServiceInterface {
   public function encrypt($text, EncryptionProfileInterface $encryption_profile) {
     if ($this->validate($text, $encryption_profile)) {
       $key = $encryption_profile->getEncryptionKey();
-      return $encryption_profile->getEncryptionMethod()->encrypt($text, $key->getKeyValue());
+      return $encryption_profile->getEncryptionMethod()->encrypt($text, $key);
     }
   }
 
@@ -66,7 +66,7 @@ class EncryptService implements EncryptServiceInterface {
   public function decrypt($text, EncryptionProfileInterface $encryption_profile) {
     if ($this->validate($text, $encryption_profile)) {
       $key = $encryption_profile->getEncryptionKey();
-      return $encryption_profile->getEncryptionMethod()->decrypt($text, $key->getKeyValue());
+      return $encryption_profile->getEncryptionMethod()->decrypt($text, $key);
     }
   }
 
diff --git a/src/EncryptionMethodInterface.php b/src/EncryptionMethodInterface.php
index 2e538ac..136573c 100644
--- a/src/EncryptionMethodInterface.php
+++ b/src/EncryptionMethodInterface.php
@@ -9,6 +9,7 @@ namespace Drupal\encrypt;
 use Drupal\Component\Plugin\ConfigurablePluginInterface;
 use Drupal\Component\Plugin\PluginInspectionInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\key\KeyInterface;
 
 /**
  * Provides an interface for EncryptionMethod plugins.
@@ -22,39 +23,39 @@ interface EncryptionMethodInterface extends ContainerFactoryPluginInterface, Plu
    *
    * @param string $text
    *   The text to be encrypted.
-   * @param string $key
+   * @param \Drupal\key\KeyInterface $key
    *   The key to encrypt the text with.
    *
    * @return string
    *   The encrypted text
    */
-  public function encrypt($text, $key);
+  public function encrypt($text, KeyInterface $key);
 
   /**
    * Decrypt text.
    *
    * @param string $text
    *   The text to be decrypted.
-   * @param string $key
+   * @param \Drupal\key\KeyInterface $key
    *   The key to decrypt the text with.
    *
    * @return string
    *   The decrypted text
    */
-  public function decrypt($text, $key);
+  public function decrypt($text, KeyInterface $key);
 
   /**
    * Check dependencies for the encryption method.
    *
    * @param string $text
    *   The text to be checked.
-   * @param string $key
+   * @param \Drupal\key\KeyInterface $key
    *   The key to be checked.
    *
    * @return array
    *   An array of error messages, providing info on missing dependencies.
    */
-  public function checkDependencies($text = NULL, $key = NULL);
+  public function checkDependencies($text = NULL, KeyInterface $key = NULL);
 
   /**
    * Get the label.
diff --git a/src/Entity/EncryptionProfile.php b/src/Entity/EncryptionProfile.php
index acadc5d..bfd0bcb 100644
--- a/src/Entity/EncryptionProfile.php
+++ b/src/Entity/EncryptionProfile.php
@@ -237,7 +237,7 @@ class EncryptionProfile extends ConfigEntityBase implements EncryptionProfileInt
         if (!$text) {
           $text = $random->string();
         }
-        $dependency_errors = $encryption_method->checkDependencies($text, $selected_key->getKeyValue());
+        $dependency_errors = $encryption_method->checkDependencies($text, $selected_key);
         $errors = array_merge($errors, $dependency_errors);
       }
     }
diff --git a/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/ConfigTestEncryptionMethod.php b/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/ConfigTestEncryptionMethod.php
index 859b14b..522bd66 100644
--- a/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/ConfigTestEncryptionMethod.php
+++ b/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/ConfigTestEncryptionMethod.php
@@ -11,6 +11,7 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\encrypt\EncryptionMethodInterface;
 use Drupal\encrypt\Plugin\EncryptionMethod\EncryptionMethodBase;
 use Drupal\encrypt\Plugin\EncryptionMethodPluginFormInterface;
+use Drupal\key\KeyInterface;
 
 /**
  * ConfigTestEncryptionMethod testing class.
@@ -27,7 +28,7 @@ class ConfigTestEncryptionMethod extends EncryptionMethodBase implements Encrypt
   /**
    * {@inheritdoc}
    */
-  public function checkDependencies($text = NULL, $key = NULL) {
+  public function checkDependencies($text = NULL, KeyInterface $key = NULL) {
     $errors = array();
     return $errors;
   }
@@ -35,17 +36,17 @@ class ConfigTestEncryptionMethod extends EncryptionMethodBase implements Encrypt
   /**
    * {@inheritdoc}
    */
-  public function encrypt($text, $key, $options = array()) {
-    $prefix = $key . $this->getConfiguration()['mode'];
+  public function encrypt($text, KeyInterface $key, $options = array()) {
+    $prefix = $key->getKeyValue() . $this->getConfiguration()['mode'];
     return str_rot13($prefix . $text);
   }
 
   /**
    * {@inheritdoc}
    */
-  public function decrypt($text, $key, $options = array()) {
+  public function decrypt($text, KeyInterface $key, $options = array()) {
     $decoded = str_rot13($text);
-    $prefix = $key . $this->getConfiguration()['mode'];
+    $prefix = $key->getKeyValue() . $this->getConfiguration()['mode'];
     // Strip out key, to retrieve original text.
     if (substr($decoded, 0, strlen($prefix)) == $prefix) {
       return substr($decoded, strlen($prefix));
diff --git a/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/TestEncryptionMethod.php b/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/TestEncryptionMethod.php
index a5d2e58..549c9df 100644
--- a/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/TestEncryptionMethod.php
+++ b/tests/modules/encrypt_test/src/Plugin/EncryptionMethod/TestEncryptionMethod.php
@@ -9,6 +9,7 @@ namespace Drupal\encrypt_test\Plugin\EncryptionMethod;
 
 use Drupal\encrypt\EncryptionMethodInterface;
 use Drupal\encrypt\Plugin\EncryptionMethod\EncryptionMethodBase;
+use Drupal\key\KeyInterface;
 
 /**
  * TestEncryptionMethod testing class.
@@ -25,7 +26,7 @@ class TestEncryptionMethod extends EncryptionMethodBase implements EncryptionMet
   /**
    * {@inheritdoc}
    */
-  public function checkDependencies($text = NULL, $key = NULL) {
+  public function checkDependencies($text = NULL, KeyInterface $key = NULL) {
     $errors = array();
     return $errors;
   }
@@ -33,18 +34,18 @@ class TestEncryptionMethod extends EncryptionMethodBase implements EncryptionMet
   /**
    * {@inheritdoc}
    */
-  public function encrypt($text, $key, $options = array()) {
-    return str_rot13($key . $text);
+  public function encrypt($text, KeyInterface $key, $options = array()) {
+    return str_rot13($key->getKeyValue() . $text);
   }
 
   /**
    * {@inheritdoc}
    */
-  public function decrypt($text, $key, $options = array()) {
+  public function decrypt($text, KeyInterface $key, $options = array()) {
     $decoded = str_rot13($text);
     // Strip out key, to retrieve original text.
-    if (substr($decoded, 0, strlen($key)) == $key) {
-      return substr($decoded, strlen($key));
+    if (substr($decoded, 0, strlen($key->getKeyValue())) == $key->getKeyValue()) {
+      return substr($decoded, strlen($key->getKeyValue()));
     }
     else {
       return "invalid key";
