aes - How to decrypt Rijndael-256 in python, used in Quickbooks PHP API - Stack Overflow

PHOTO EMBED

Fri May 29 2020 11:29:28 GMT+0000 (UTC)

Saved by @Amna #php

function encrypt($key, $plain, $salt = null)
    {
        echo $key;
    $plain = serialize(array( $plain, $salt ));

    $crypt = mcrypt_module_open('rijndael-256', '', 'ofb', '');

    if (false !== stripos(PHP_OS, 'win') and 
        version_compare(PHP_VERSION, '5.3.0')  == -1) 
    {
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypt), MCRYPT_RAND);    
    }
    else
    {
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypt), MCRYPT_DEV_URANDOM);
    }

    $ks = mcrypt_enc_get_key_size($crypt);

    $key = substr(md5($key), 0, $ks);
    echo strlen($key);
    mcrypt_generic_init($crypt, $key, $iv);
    $encrypted = base64_encode($iv . mcrypt_generic($crypt, $plain));
    mcrypt_generic_deinit($crypt);
    mcrypt_module_close($crypt);

    return $encrypted;
}
content_copyCOPY

https://stackoverflow.com/questions/62083689/how-to-decrypt-rijndael-256-in-python-used-in-quickbooks-php-api