import zend mcrypt tests
[hiphop-php.git] / hphp / test / zend / bad / ext-mcrypt / mcrypt_cbc_variation2.php
blobc550c6af83ff639296e0dc6b4573940cc5860f10
1 <?php
2 /* Prototype : string mcrypt_cbc(string cipher, string key, string data, int mode, string iv)
3 * Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
4 * Source code: ext/mcrypt/mcrypt.c
5 * Alias to functions:
6 */
8 echo "*** Testing mcrypt_cbc() : usage variation ***\n";
10 // Define error handler
11 function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
12 if (error_reporting() != 0) {
13 // report non-silenced errors
14 echo "Error: $err_no - $err_msg, $filename($linenum)\n";
17 set_error_handler('test_error_handler');
19 // Initialise function arguments not being substituted (if any)
20 $cipher = MCRYPT_TRIPLEDES;
21 $data = b'string_val';
22 $mode = MCRYPT_ENCRYPT;
23 $iv = b'01234567';
25 //get an unset variable
26 $unset_var = 10;
27 unset ($unset_var);
29 // define some classes
30 class classWithToString
32 public function __toString() {
33 return b"Class A object";
37 class classWithoutToString
41 // heredoc string
42 $heredoc = b<<<EOT
43 hello world
44 EOT;
46 // get a resource variable
47 $fp = fopen(__FILE__, "r");
49 // add arrays
50 $index_array = array (1, 2, 3);
51 $assoc_array = array ('one' => 1, 'two' => 2);
53 //array of values to iterate over
54 $inputs = array(
56 // int data
57 'int 0' => 0,
58 'int 1' => 1,
59 'int 12345' => 12345,
60 'int -12345' => -2345,
62 // float data
63 'float 10.5' => 10.5,
64 'float -10.5' => -10.5,
65 'float 12.3456789000e10' => 12.3456789000e10,
66 'float -12.3456789000e10' => -12.3456789000e10,
67 'float .5' => .5,
69 // array data
70 'empty array' => array(),
71 'int indexed array' => $index_array,
72 'associative array' => $assoc_array,
73 'nested arrays' => array('foo', $index_array, $assoc_array),
75 // null data
76 'uppercase NULL' => NULL,
77 'lowercase null' => null,
79 // boolean data
80 'lowercase true' => true,
81 'lowercase false' =>false,
82 'uppercase TRUE' =>TRUE,
83 'uppercase FALSE' =>FALSE,
85 // empty data
86 'empty string DQ' => "",
87 'empty string SQ' => '',
89 // object data
90 'instance of classWithToString' => new classWithToString(),
91 'instance of classWithoutToString' => new classWithoutToString(),
93 // undefined data
94 'undefined var' => @$undefined_var,
96 // unset data
97 'unset var' => @$unset_var,
99 // resource variable
100 'resource' => $fp
103 // loop through each element of the array for key
105 foreach($inputs as $valueType =>$value) {
106 echo "\n--$valueType--\n";
107 var_dump(bin2hex(mcrypt_cbc($cipher, $value, $data, $mode, $iv)));
110 fclose($fp);
113 ===DONE===