function aes_get_key in AES encryption 7
Same name and namespace in other branches
- 5 aes.module \aes_get_key()
- 6 aes.module \aes_get_key()
Gets the current key used for the encryption system. If there's currently no key defined, this function will generate one, store it, and return it.
Return value
string The key.
4 calls to aes_get_key()
- aes_config_submit in ./
aes.admin.inc - Submits aes_config form.
- aes_decrypt in ./
aes.module - Decrypts a string of encrypted data.
- aes_enable in ./
aes.install - Implements hook_enable().
- aes_encrypt in ./
aes.module - Encrypts a string.
File
- ./
aes.module, line 332 - Main file of the AES encryption module.
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;
}