Archive for the "Hosting" Category

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!