note 94096 modified in book.mcrypt by danbrown
| From: | danbrown@php.net | Date: | Fri, 16 Oct 2009 15:38:03 +0000 |
| Subject: | note 94096 modified in book.mcrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161812@lists.php.net to get a copy of this message | ||
When using 3DES between PHP and C#, it is to be noted that there are subtle differences that if not
strictly observed, will result in annoying problem encrypt/decrypt data.
1), When using a 16 bytes key, php and c# generates total different outcome string. it seems that a
24 bytes key is required for php and c# to work alike.
2), php doesnt have a "padding" option, while c# has 3 (?). My work around is to add nulls
i.e. chr(0) to the end of the source string to make its size times of 8, while in c#,
PaddingMode.Zeros is required.
3) the key size has to be times of 8, in php, to make it work for c#.
--was--
When using 3DES between PHP and C#, it is to be noted that there are subtle differences that if not
strictly observed, will result in annoying problem encrypt/decrypt data.
1), When using a 16 bytes key, php and c# generates total different outcome string. it seems that a
24 bytes key is required for php and c# to work alike.
2), php doesnt have a "padding" option, while c# has 3 (?). My work around is to add nulls
i.e. chr(0) to the end of the source string to make its size times of 8, while in c#,
PaddingMode.Zeros is required.
3) the key size has to be times of 8, in php, to make it work for c#.
you may also find this url helpful http://www.sanity-free.org/131/triple_des_between_php_and_csharp.html
http://php.net/manual/en/book.mcrypt.php