[PHP-users 22264]Re: mcrypt_ecbはWindows版で使えるか?

UNO Shintaro uno @ venus.dti.ne.jp
2004年 6月 18日 (金) 13:38:55 JST


>(1)Windows版のPHPでmcrypt_ecbは使えるのでしょうか?
>(2)Win2K Serverへのインストール方法は(何か特別な方法が必要なのか)?
>(2)PHP3のmcrypt_ecbとPHP4のそれの間で、現在判明している非互換点などはあ
>りますか?

PHP3との非互換点については分かりませんけれど、
「使えるかどうか」と「インストール方法」について。


拡張モジュール ext/mcrypt (php_mcrypt.dll) 自体はWindows版PHP4に
付属しています。このモジュールを有効にできればmcrypt関数が使えます。

で、ext/mcryptモジュールは、libmcryptというライブラリのWindows用に
コンパイルされたバイナリ(libmcrypt.dll)に依存していて、これがPHPに
付属していないので、mcrypt関数を使うためにはこれの入手が必須です。
libmcrypt.dllを持ってきてsystem32ディレクトリに配置すれば、php.ini
の設定でphp_mcrypt.dllを有効にすることができるようになります。

#libmcryptの本家ではWindowsに対応していませんが、検索エンジンで探すと
#Windowsに対応したlibmcrypt.dllのバイナリが比較的容易に見付かります。

で、こんな感じになります。

test.php:
<?php
$key = "this is a very secret key";
$input = "Let us meet at 9 o'clock at the secret place.";

$encrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT);
$decrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, $encrypted_data, MCRYPT_DECRYPT);

echo $input . "\n";
echo $encrypted_data . "\n";
echo $decrypted_data . "\n";
?>


C:\work>php -q test.php
PHP Warning:  mcrypt_ecb(): Size of key is too large for this algorithm in C:\work\test.php on line 5
PHP Warning:  mcrypt_ecb(): Attempt to use an empty IV, which is NOT recommend in C:\work\test.php on line 5
PHP Warning:  mcrypt_ecb(): Size of key is too large for this algorithm in C:\work\test.php on line 6
PHP Warning:  mcrypt_ecb(): Attempt to use an empty IV, which is NOT recommend in C:\work\test.php on line 6
Let us meet at 9 o'clock at the secret place.
ソ\C*Rナ・オ栢メ・襷ニH|・=ミ(%I咾
Let us meet at 9 o'clock at the secret place.

C:\work>

-- 
UNO Shintaro, 宇野 信太郎
mailto:uno @ venus.dti.ne.jp
http://www.venus.dti.ne.jp/~uno/


PHP-users メーリングリストの案内