Someone here who helps me please. I am encrypting data with aes256, link is in my function:
encriptar(_encrypt) {
return this.aes256.encrypt(this.secureKey, this.secureIV, _encrypt )
.then((encrypt_) => {
this.desencriptar(encrypt_);
return encrypt_;
})
.catch((error: any) => console.error(error));
}
the value of this.secureKey ="12345678910123456789012345678901"
and this.SecureIv = "1234567891123456"
Which in ionic encrypts and decrypts correctly. the error occurs when this encrypted data is sent by api rest and my php backend is not decrypted by my php function:
define('AES_256_CBC', 'aes-256-cbc');
$encryption_key = "12345678910123456789012345678901";
$iv = "1234567891123456";
$encrypted = "0csm3Gjm6Q+ZNa+sjI+SYg== ";
$encrypted = $encrypted . ':' . $iv;
$parts = explode(':', $encrypted); echo "encriptado base64 : ".base64_encode($encrypted);
echo "<br>";
echo $parts[0];
echo "<br>";
$decrypted = openssl_decrypt(base64_decode($parts[0]) , AES_256_CBC, $encryption_key, 0, $iv) ;
echo "Decrypted: $decrypted\n";