Jump to content

Updating custom product field via API modifies a base64 encrypted value


Recommended Posts

I'm trying to store encrypted data in WHMCS custom product fields. The data is encrypted externally then put into its own base64 encoded variable and passed to WHMCS via the external API. The encryption/decryption works locally without issue when the encrypted output is passed directly to the decryption input:


For instance

$pass = '989098';

echo "<br/><br/>Encrypting: $pass<br/>";

$pass= encrypt($pass);

echo "Encrypted: $pass<br/>";

$tmppass = decrypt($pass);

echo "Decrypted: $pass<br/><br/>";


Returns this just fine:


Encrypting: 989098

Encrypted: gOpFhNvBb4uQRfNoeLpdHkRiNjhzN01qVzRZRE51VnBPYk4rU2c9PQ==

Decrypted: 989098


I add this data into WHMCS custom fields using the API as follows:


$postfields["customfields"] = base64_encode(serialize(array("103"=>"$pass")));


When pulling it back from WHMCS and putting it into the decryption algorithm, decryption fails with: "error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length".


The initial and return strings appear to look exactly the same. If I manually paste the base64 output from the app directly into the WHMCS field and run the external app again, it works fine.


Apparently using the external API to load the string changes something when it's uploaded. I've tried everything I can think of like cleaning the return of hidden characters. Any ideas?

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.

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