dear all:
i'm new to the list and crypto++. i am trying to write a simple
crypto++ program that decrypts an aes encrypted string returned from a
web server by php's mcrypt. i've put in several hours already without
success. please help!
--
Best,
Peter
=========== output of the mcrypt script =================
IV: b9MUxwBQMcTSFTKD194qbaoBfJh/NjhhZ04PuwfBL2o=
KEY: a7bc27daf59679de9db7b68b1ef92785
ENCRYPTED: yZXVQ7xT2ejGekyxv+Z8EvQYvXYZ7aJ6JPUP
This is very important data
=============== here's the PHP mcrypt script: ===============
<?php
/* Open the cipher */
$td = mcrypt_module_open('rijndael-256', '', 'ofb', '');
/* Create the IV and determine the keysize length, used MCRYPT_RAND
* on Windows instead */
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
echo "IV: " . base64_encode($iv) . "<br>";
$ks = mcrypt_enc_get_key_size($td);
/* Create key */
$key = substr(md5('very secret key'), 0, $ks);
echo "KEY: " . $key . "<br>";
/* Intialize encryption */
mcrypt_generic_init($td, $key, $iv);
/* Encrypt data */
$encrypted = mcrypt_generic($td, 'This is very important data');
echo "ENCRYPTED: " . base64_encode ($encrypted) . "<br>";
/* Terminate encryption handler */
mcrypt_generic_deinit($td);
/* Initialize encryption module for decryption */
mcrypt_generic_init($td, $key, $iv);
/* Decrypt encrypted string */
$decrypted = mdecrypt_generic($td, $encrypted);
/* Terminate decryption handle and close module */
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
/* Show string */
echo trim($decrypted) . "\n";
?>