I have a PHP server that decrypts data in 3DES with CFB mode
I am encrypting in PHP:
$montant = "500"; $message_crypte = mcrypt_encrypt(MCRYPT_3DES, "N4y1FRDRJ7wn7eJNnWaahCIS", $montant, ,CRYPT_MODE_CFB, "NCNPJDcR"); $montant = base64_encode($message_crypte);
This script in PHP is fine with another system.
And I want to encrypt in Java:
public class CryptData { private KeySpec keySpec; private SecretKey key; private IvParameterSpec iv; public CryptData(String keyString, String ivString) { try { final MessageDigest md = MessageDigest.getInstance("md5"); final byte[] digestOfPassword = md.digest(Base64 .decodeBase64(keyString.getBytes("ISO-8859-1"))); final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); for (int j = 0, k = 16; j < 8;) { keyBytes[k++] = keyBytes[j++]; }
I have not the same result in PHP and in Java
How to change Java processing to get the same result as PHP?
source share