Webper Posted November 18, 2014 Share Posted November 18, 2014 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? 0 Quote Link to comment Share on other sites More sharing options...
Webper Posted November 18, 2014 Author Share Posted November 18, 2014 Found the problem. There was an error in my encryption method that inserted a blank space if it was called from the form. So if I hard set it there was no issue but when it populated it there was an extra space. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.