We had a need to decrypt plesk passwords upon request to interface with another system so after a bit of playing about the following code is what we landed at:-
<?php $key = file_get_contents("/etc/psa/private/secret_key"); $hash = explode(' Just pass the AES string in its entirety from the psa database. Hope this helps people :) James , '$AES-128-CBC$some-example-string==$some-example-salt=='); $iv = base64_decode($hash); $ct = base64_decode($hash); $dec = str_replace("\0", "", mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ct , MCRYPT_MODE_CBC, $iv)); echo($dec); ?>
Just pass the AES string in its entirety from the psa database.
Hope this helps people 🙂