equivalent of mysql aes_decrypt in php?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • veg_all@yahoo.com

    equivalent of mysql aes_decrypt in php?

    I am using AES_DECRYPT and AES_DECRYPT to store my datat in mysql
    databases. I want to be able to download these as csv files and have a
    php script decrypt them. I can use bin2hex to convert to text , but I
    cant figure out how to decrypt the hex to plaintext using php? I have
    tried this without success, as AES is not recognized.

    $input = 'some encrypted data in hexadecimal';

    $len = strlen ( $input );
    $input = pack("H" . $len, $input );

    $td = mcrypt_module_o pen( 'AES' , '', 'ecb', '');
    $iv = mcrypt_create_i v (mcrypt_enc_get _iv_size($td), MCRYPT_RAND );
    mcrypt_generic_ init($td, $key, $iv);

    $decrypted = mdecrypt_generi c($td, $input );

Working...