467,076 Members | 911 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,076 developers. It's quick & easy.

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


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
  • viewed: 1709

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Matt McKay | last post: by
4 posts views Thread by believein@email.it | last post: by
5 posts views Thread by sylvian stone | last post: by
5 posts views Thread by ~~~ .NET Ed ~~~ | last post: by
2 posts views Thread by osmarjunior | last post: by
reply views Thread by E. Recio | last post: by
3 posts views Thread by =?UTF-8?Q?Ahmad_=E3=8B=A1_Baitalmal?= | last post: by
4 posts views Thread by Sylvie | last post: by
3 posts views Thread by KBS Developer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.