You are here

function aes_get_key in AES encryption 6

Same name and namespace in other branches
  1. 5 aes.module \aes_get_key()
  2. 7 aes.module \aes_get_key()
4 calls to aes_get_key()
aes_config_submit in ./aes.module
aes_decrypt in ./aes.module
aes_decrypt
aes_enable in ./aes.module
aes_encrypt in ./aes.module
aes_encrypt

File

./aes.module, line 445

Code

function aes_get_key() {
  $storage_method = variable_get("aes_key_storage_method", "database");
  if ($storage_method == "Database") {
    $key = variable_get("aes_key", false);
    if ($key === false) {
      $key = aes_make_key();
      aes_store_key($key);
      watchdog("aes", "AES module made a new key since one couldn't be found by using the database storage method.");
    }
  }
  if ($storage_method == "File") {
    $key = file_get_contents(variable_get("aes_key_path", ""));
    if ($key === false) {
      $key = aes_make_key();
      aes_store_key($key);
      watchdog("aes", "AES module made a new key since one couldn't be found by using the file storage method.");
    }
  }
  return $key;
}