You are here

public function EncryptionTrait::getEncryptionKey in Encryption 8

Same name and namespace in other branches
  1. 2.x src/EncryptionTrait.php \Drupal\encryption\EncryptionTrait::getEncryptionKey()

Gets the `$settings['encryption_key']` value from settings.php.

Return value

string|null The encryption key or null if validation fails.

2 calls to EncryptionTrait::getEncryptionKey()
EncryptionTrait::decrypt in src/EncryptionTrait.php
Decrypt a value using the encryption key from settings.php.
EncryptionTrait::encrypt in src/EncryptionTrait.php
Encrypt a value using the encryption key from settings.php.

File

src/EncryptionTrait.php, line 97

Class

EncryptionTrait
Provides basic encryption/decryption methods.

Namespace

Drupal\encryption

Code

public function getEncryptionKey() {
  $key = base64_decode(Settings::get('encryption_key'));

  // Make sure the key is the correct size.
  if (strlen($key) === 32) {
    return $key;
  }
}