Menu

#13 Need information to create a compatible windows Rijndael

open
nobody
Portability (1)
5
2014-08-26
2006-09-22
Anonymous
No

Hello,

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

In php I use the code below[1] to encrypt with a 256
Bit Key and a 256 Bit block cipher.
My windows code has the same specs, but the result 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[2] -
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).

Thanks a lot,
Jens

[1]
$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);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
}

[2] http://forums.mysql.com/read.php?30,60443,84327

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.