Hướng dẫn aes/cbc/pkcs5padding php - aes / cbc / pkcs5padding php
I must match an encrypted JSON object from Java to PHP but I failed to do so. Tried almost all solutions on stackoverflow, still no luck. DOC says field must be obtained through AES encryption of the JSON representation of all the fields the merchant wants to send. Encryption algorithm must be AES/CBC/PKCS5Padding and must use as encrypting key the one provided. The initialization vector to be used for data encryption must be 16 bytes length equal to 0. Encrypted byte array must encoded to base64. {"addrMatch":"N"} should convert to q8zzcOYHKggpSFXdmdZdObe2R/1EWnFgco2FJzjhtJQ= I have the following code:
Here is my code on PHP without luck:
I produce : Bpo0neCnY+dFrdISLYcefU8sqhX/4HSr5Io+zUe4sro= Any help would be appreciated.
import android.support.annotation.Nullable;
import android.util.Base64;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/**
* AesCipher
* Encode/Decode text by password using AES-128-CBC algorithm |