Skip to content

Commit

Permalink
LDAP: Fix encrypted password generation to use the api function which…
Browse files Browse the repository at this point in the history
… is updated and not the local function that ended being different - refs BT#20849 and BT#22020
  • Loading branch information
NicoDucou committed Oct 30, 2024
1 parent 4cef771 commit e63569a
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions tests/scripts/ldap_encrypt_admin_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,8 @@
}

if (!empty(api_get_configuration_value('ldap_admin_password_salt'))) {
echo "The encrypted password is : " . encrypt(api_get_configuration_value('ldap_admin_password_salt'), $password) .PHP_EOL;
echo "The encrypted password is : " . api_encrypt_hash($password, api_get_configuration_value('ldap_admin_password_salt')) .PHP_EOL;
} else {
echo "There is no salt defined in app/config/configuration.php for variable 'ldap_admin_password_salt'".PHP_EOL.PHP_EOL;
}


function encrypt($secret, $data)
{
$secret = hex2bin($secret);
$iv = random_bytes(12);
$tag = '';

$encrypted = openssl_encrypt(
$data,
'aes-256-gcm',
$secret,
OPENSSL_RAW_DATA,
$iv,
$tag,
'',
16
);

return base64_encode($iv) . base64_encode($encrypted . $tag);
}

0 comments on commit e63569a

Please sign in to comment.