By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

How exactly does mcrypt implement rijndael-256 and how to make compatible

P: n/a

I try to program a Rijndael encryption in Windows which has to be
compatible with php.

In php I use the code below to encrypt with a 256 Bit Key and a 256 Bit
block cipher.
My windows code has the same specs, but the outcome is different.

So far I use no iv to facilitate.

I want to get more information on mcrypt_generic - how is the data
padded to multiples of 32 - my code adds Ascii 0.
I read somewhere on the internet that mcrypt added not ascii 0 but the
ascii value of the number of the padded bytes - still with this
modification of my code the result is different.

Where is the information about the length of the encoded string stored?
My code uses the first 4 bytes (but even if I do not store the length,
the outcome is different).

If no detailed information about mcrypt is available, I would be helped
if I could find a pute php Rijndael implementation so that I can adjust
it to work with my windows code. Is such an implementation available?

Thanks a lot,
$key = 'Key';
$string = 'Plain text';
$td = mcrypt_module_open('rijndael-256', '', 'cbc', '');
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = str_repeat(chr(0), $iv_size);
if (mcrypt_generic_init($td, $key, $iv) != -1) {
$c_t = mcrypt_generic($td, $string);

Sep 22 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.