diff --git a/dbee.module b/dbee.module
index 9d910f5..0823fc9 100644
--- a/dbee.module
+++ b/dbee.module
@@ -13,6 +13,7 @@ use Drupal\Core\Database\Query\AlterableInterface;
 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\encrypt\Entity\EncryptionProfile;
+use Drupal\encrypt\Exception\EncryptException;
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Routing\RouteMatchInterface;
 
@@ -65,12 +66,16 @@ function dbee_encrypt($string) {
   if (dbee_email_to_alter($string)) {
     // The email address is valid.
     $encryption_profile = EncryptionProfile::load(DBEE_ENCRYPT_NAME);
-    $encrypted = utf8_encode(Drupal::service('encryption')->encrypt($string, $encryption_profile));
-    // Ensure the encrypted value is correct.
-    // (Check if the email address is no longer valid.)
-    $decrypt = dbee_decrypt($encrypted);
-    if (!dbee_email_to_alter($encrypted) && dbee_email_to_alter($decrypt)) {
-      return $encrypted;
+    try {
+      $encrypted = utf8_encode(\Drupal::service('encryption')->encrypt($string, $encryption_profile));
+      // Ensure the encrypted value is correct.
+      // (Check if the email address is no longer valid.)
+      $decrypt = dbee_decrypt($encrypted);
+      if (!dbee_email_to_alter($encrypted) && dbee_email_to_alter($decrypt)) {
+        return $encrypted;
+      }
+    }
+    catch (EncryptException $e) {
     }
   }
   // Do not alter the data if:
@@ -103,11 +108,15 @@ function dbee_decrypt($string, $prev_encrypt = FALSE) {
     // The email address is not valid.
     $encrypt_profile = (!$prev_encrypt) ? DBEE_ENCRYPT_NAME : DBEE_PREV_ENCRYPT_NAME;
     $encryption_profile = EncryptionProfile::load($encrypt_profile);
-    $uncrypted_mail = utf8_encode(Drupal::service('encryption')->decrypt(utf8_decode($string), $encryption_profile));
-    // Check whether the decrypted email address is valid before returning it.
-    if ($uncrypted_mail && dbee_email_to_alter($uncrypted_mail)) {
-      // The decrypted value is a valid email address, so return it.
-      return $uncrypted_mail;
+    try {
+      $uncrypted_mail = utf8_encode(\Drupal::service('encryption')->decrypt(utf8_decode($string), $encryption_profile));
+      // Check whether the decrypted email address is valid before returning it.
+      if (dbee_email_to_alter($uncrypted_mail)) {
+        // The decrypted value is a valid email address, so return it.
+        return $uncrypted_mail;
+      }
+    }
+    catch (EncryptException $e) {
     }
   }
   // Do not alter the data if:
