1--TEST--
2mcrypt filters
3--SKIPIF--
4<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
5--FILE--
6<?php
7foreach (stream_get_filters() as $f) {
8	if ($f == "mcrypt.*" || $f == "mdecrypt.*") {
9	   echo "FOUND\n";
10	}
11}
12
13$secretfile = 'secert-file.tmp';
14$passphrase = 'My secret';
15
16$iv = substr(md5('iv'.$passphrase, true), 0, 8);
17$key = substr(md5('pass1'.$passphrase, true) .
18               md5('pass2'.$passphrase, true), 0, 24);
19$opts = array('iv'=>$iv, 'key'=>$key);
20
21$fp = fopen($secretfile, 'wb');
22stream_filter_append($fp, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
23fwrite($fp, 'Secret secret secret data');
24fclose($fp);
25
26echo md5_file($secretfile)."\n";
27
28$fp = fopen($secretfile, 'rb');
29stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts);
30$data = stream_get_contents($fp);
31fclose($fp);
32
33echo $data."\n";
34
35@unlink($secretfile);
36--EXPECTF--
37FOUND
38FOUND
39
40Deprecated: stream_filter_append(): mcrypt and mdecrypt stream filters have been deprecated in %s%emcrypt_filters.php on line 17
4132e14bd3c31f2bd666e4290ebdb166a7
42
43Deprecated: stream_filter_append(): mcrypt and mdecrypt stream filters have been deprecated in %s%emcrypt_filters.php on line 24
44Secret secret secret data
45