WHMCS Password Encryption and Decryption

So at my work, we just bought out a couple of other hosting companies, and needed to bring all their customer data from WHMCS into our WHMCS install.

We figured ‘no problems, WHMCS has a merge tool’.   Yeah, that didn’t work at all!

So.  We sat down and wrote one!

Where things almost came unstuck, was transferring passwords.  WHMCS stores all manner of passwords – customer passwords, hosting account passwords, even server passwords.  For that matter, they also store credit card details.  And they’re all stored Encrypted!

After discovering this helpful class, and mucking about for a few hours working out how they use the hash, I was ready to go! Using it is a breeze.  You just need your cc_encryption_hash from your WHMCS configuration.php, and off you go.

If you were to run this code, it would display ‘MyPassword’.

So in my case, transferring between two WHMCS installations, I use a code block like the following:

Assuming you had the encrypted password from the old system in $oldpass, you will now have the password for the new system in $newpass.

Hopefully this helps someone! Google was no help at all for re-encrypting the password!


4 Responses

You can follow any responses to this entry through the RSS 2.0 feed.

You can leave a response, or trackback from your own site.

  1. Yanko Ivanov says:

    Thank you, I just stumbled across your article, facing the same problem. Hopefully it’ll get the problem solved. 🙂

  2. Harry Lewis says:

    Awesome. Thanks so much for posting this- until now i’ve been using WHMCS’s external API to decrypt() into plaintext and encrypt() again for insertion… One string at a time! Doing it that way is incredibly slow- tens of thousands of http requests which sometimes fail.

    This is going to speed things up dramatically!

  3. It’s worth nothing that hash_crypt.php is no longer available

    However this file is functionally identical to lib/framework/lib_crypto.php from the smartnet framework at https://sourceforge.net/projects/warp-cms/files/smart-framework/ – however the class name is SmartCryptoCipherHash, not hash_encryption in the smartnet framework

Leave a Reply