PHPと.NETで暗号化の結果がマッチしない問題

PHPで暗号化して.NETで復号化という処理をしようとしたところ結果が一致しないと言うことが起こりました。
色々ぐぐった結果PHPのマニュアルがヒットしましたヨ。。。

Mcript – Dot NET – 3DES problem.

This is a solution for the 3DES algorithm’s problem in his interaction with .NET TripleDESCryptoServiceProvider (System.Security.Cryptography), CBC mode, because the key is completed to 192bits and the text is padded.

So, we has two problems:
– The key’s completion was posted by “jesse at pctest dot com”.
– The text padding also posted by him, but the completion is a little different. The padding bytes are 0x01 to 0x08 because completed to 8 bytes blocks. If your text have a whole number of 8 bytes blocks, the algorithm add other block with padded bytes (0x08).

This is a function to encrypt a text in a equal form that the Dot NET algorithm:

PHP: mcrypt_encrypt – Manual

どーしても一致しないのでpythonでやってもらったりもしたんですが、結局どういうことなんだろう。((pyDesというのでやったら.NETと同じ結果になった))
これはPHPのバグってことなんですかね??????

ともあれtripledesで暗号化する際にはご注意くださいませε=(~Д~;)

コメント

タイトルとURLをコピーしました