I am encrypting text in IONIC using @ionic-native/aes-256/ngx library and trying to decrypt the same in PHP but am unable to do so.
Here's the data :
Key : 12345678901234567890123456789012 (32bit) IV : 1234567890123456 Plain Text : ABCD Encrypted in IONIC : W2/PbR8z0sKBblfd4ezO1DKI/7UrB/egwDEGyw7w9tY=
It's decrypting in IONIC but not in PHP. In PHP I tried encryption of the same text using the same keys but also I am getting different encrypted data. PHP encrypted data for string ABCD : 5JvCGZhhM12hA9Tz/ldBvw==
Can somebody please explain if I am missing anything?
import { AES256 } from ‘@ionic-native/aes-256/ngx’; constructor(public aes:AES256){} encrypt(key, iv, data){ return this.aes.encrypt(key, iv, data); } output : "W2/PbR8z0sKBblfd4ezO1DKI/7UrB/egwDEGyw7w9tY= " $iv = “1234567890123456”; $key = “12345678901234567890123456789012”; $encrypted = "W2/PbR8z0sKBblfd4ezO1DKI/7UrB/egwDEGyw7w9tY= "; $decrypted = openssl_decrypt($encrypted, “AES-256-CBC”, $key, 0, $iv); echo $decrypted; Encrypted data in IONIC and PHP are different. I want to decrypt the text in PHP which was done using IONIC
hY0wTq6xwc6ni01G. With this, the ciphertext can indeed be decrypted, namely as Base64 string:arqWj4Qs3nDX5iYw9blqyA==. An incorrect decryption is unlikely due to the valid padding with seven 0x07 bytes.ABCDthat you expect. So either your expectation is wrong or the result is possibly a second ciphertext whose decryption results inABCD.5JvCGZhhM12hA9Tz/ldBvw==whose decoded length is 16 bytes. What you have give as an example ciphertext has a decoded length of 32 bytes. This implies to me that you are using a longer and therefore wholly different plaintext input for your Ionic test code, to say nothing of if the key and IV match.