function aes_get_password in AES encryption 7
Same name and namespace in other branches
- 5 aes.module \aes_get_password()
- 6 aes.module \aes_get_password()
Gets a users password, in plain text, or in it's encrypted form.
// Implements hook_user_view().
function mymodule_user_view($account, $view_mode, $langcode) {
if (aes_password_exists($account->uid)) {
$password = aes_get_password($uid, TRUE);
$account->content['info']['aes_password'] = array(
'#type' => 'user_profile_item',
'#title' => t('User password'),
'#markup' => '<div id="aes_password">' . $password . '</div>',
);
}
}
Parameters
int $uid: The user ID.
bool $decrypt: (optional) Whether to decrypt the password before returning it, or not. Defaults to FALSE.
Return value
bool|string The password in plain text on success, FALSE otherwise.
See also
2 calls to aes_get_password()
- aes_ajax_callback in ./
aes.module - Callback for user's password ajax link.
- aes_password_exists in ./
aes.module - Checks if a users password exists.
1 string reference to 'aes_get_password'
- aes_menu in ./
aes.module - Implements hook_menu().
File
- ./
aes.module, line 309 - Main file of the AES encryption module.
Code
function aes_get_password($uid, $decrypt = FALSE) {
$password = db_select('aes_passwords', 'p')
->fields('p', array(
'pass',
))
->condition('uid', $uid)
->execute()
->fetchField();
if (empty($password)) {
return FALSE;
}
if ($decrypt) {
return aes_decrypt($password);
}
return $password;
}