Jump to content

Decrypt Password API not working?


Recommended Posts

Hi All,

 

I've started using the API lately and am looking at implementing a few different things.

 

I have used GetClientPassword to get the hashed version of the password out of the database, and then I've tried putting it through DecryptPassword but it gives me a response of "array(2) { ["result"]=> string(5) "error" ["message"]=> string(96) "Error generating JSON encoded response: Malformed UTF-8 characters, possibly incorrectly encoded" }" what am I doing wrong?

 

The API documentation referring to DecryptPassword is non-existent.

Link to comment
Share on other sites

Hi All,

 

I've started using the API lately and am looking at implementing a few different things.

 

I have used GetClientPassword to get the hashed version of the password out of the database, and then I've tried putting it through DecryptPassword but it gives me a response of "array(2) { ["result"]=> string(5) "error" ["message"]=> string(96) "Error generating JSON encoded response: Malformed UTF-8 characters, possibly incorrectly encoded" }" what am I doing wrong?

 

The API documentation referring to DecryptPassword is non-existent.

https://developers.whmcs.com/api-reference/decryptpassword/

 

you may share the part of code that returning this error?

Link to comment
Share on other sites

https://developers.whmcs.com/api-reference/decryptpassword/

 

you may share the part of code that returning this error?

 

Here is the code; the $clientPassword['password'] variable gives a long hashed password which is giving the error message.

 

$customerpassword = $clientPassword['password'];

//Decypt Password
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,
   http_build_query(
       array(
           'action' => 'DecryptPassword',
           'username' => $username,
           'password' => $password,
           'password2' => $customerpassword,
           'responsetype' => 'json',
       )
   )
);
$decodedPassword = curl_exec($ch);
curl_close($ch);
$decodedPassword = json_decode($decodedPassword, true);

Link to comment
Share on other sites

Are you trying to decrypt the password of a client? You can't. You can only decrypt service and server passwords/hashes.

 

The client passwords are a one-way hash, using bcrypt. You can't even use a rainbow table as they are all attached with a unique salt.

 

You generally use GetClientPassword to set a session.

 

What are you trying to do?

Link to comment
Share on other sites

Hi Mark,

 

Thanks for the response.

 

**If anyone from WHMCS reads this, maybe it's time to update the API documentation to advise that the Decrypt Password function is only for specific use cases.**

 

I was hoping to be able to display a customer overview to them on a page so that they had all their info in one spot.

 

Have you got a scenario where you'd need to decrypt a service/server password/hash, as all my cPanel passwords come out in plain text when I make the JSON API call?

 

Thanks for your response.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated