The Salesforce developer has encrypted a string, eg. 0050000162 in SalesForce using encryptWithManagedIV and a key that he has shared with me and the encryption standard AES-256 CBC and passed it along in a url eg. https://a.domain.com/vEmJWoxXyhfTDSrRstf1NYpIB+s5LObcstvFVTUAcb8=
I have tried to decrypted as such
openssl_decrypt("vEmJWoxXyhfTDSrRstf1NYpIB+s5LObcstvFVTUAcb8=", "aes-256-cbc", SHARED_CRYPT_KEY);
also
openssl_decrypt(urldecode("vEmJWoxXyhfTDSrRstf1NYpIB+s5LObcstvFVTUAcb8="), "aes-256-cbc", SHARED_CRYPT_KEY);
and
openssl_decrypt(base64url_decode("vEmJWoxXyhfTDSrRstf1NYpIB+s5LObcstvFVTUAcb8="), "aes-256-cbc", SHARED_CRYPT_KEY);
function base64url_decode($base64url)
{
$base64 = strtr($base64url, '-_', '+/');
$plainText = base64_decode($base64);
return ($plainText);
}
The other developer has been able to decrypt in SalesForce with below code
Blob bEncryptKey = Blob.valueOf(encryptKey);
Blob bDataToEncrypt = EncodingUtil.base64Decode(quoteNumberEncrypted);
Blob decrypted = Crypto.decryptWithManagedIV('AES256', bEncryptKey, bDataToEncrypt);
sQuoteNumberEncrypted = decrypted.toString();
What am I missing ?
Thanks
Frank