mirror of
https://github.com/php/pecl-encryption-mcrypt.git
synced 2026-03-23 23:12:15 +01:00
Add support for PHP 8
And drop variation tests. Closes GH-6.
This commit is contained in:
committed by
Nikita Popov
parent
c672464f01
commit
11de239f9c
26
.travis.yml
26
.travis.yml
@@ -1,18 +1,26 @@
|
||||
sudo: false
|
||||
language: php
|
||||
|
||||
dist: bionic
|
||||
php:
|
||||
- 7.2
|
||||
- 7.3
|
||||
|
||||
- 7.4
|
||||
- nightly
|
||||
sudo: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
env:
|
||||
- REPORT_EXIT_STATUS=1 NO_INTERACTION=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libmcrypt-dev
|
||||
update: true
|
||||
|
||||
before_script:
|
||||
- phpize && ./configure && make
|
||||
|
||||
script:
|
||||
- make test REPORT_EXIT_STATUS=1 NO_INTERACTION=1 TESTS="--show-all"
|
||||
install:
|
||||
- phpize
|
||||
- ./configure
|
||||
- make
|
||||
script: TEST_PHP_EXECUTABLE=$(which php) php -n
|
||||
-d open_basedir= -d output_buffering=0 -d memory_limit=-1
|
||||
run-tests.php -n
|
||||
-d extension_dir=modules -d extension=mcrypt.so --show-diff
|
||||
tests
|
||||
|
||||
20
mcrypt.c
20
mcrypt.c
@@ -629,7 +629,7 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
|
||||
if (data_len == 0) {
|
||||
php_error_docref(NULL, E_WARNING, "An empty string was passed");
|
||||
RETURN_FALSE
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (data_len > INT_MAX) {
|
||||
@@ -683,7 +683,7 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
|
||||
if (data_len == 0) {
|
||||
php_error_docref(NULL, E_WARNING, "An empty string was passed");
|
||||
RETURN_FALSE
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Check blocksize */
|
||||
@@ -762,10 +762,10 @@ PHP_FUNCTION(mcrypt_generic_deinit)
|
||||
|
||||
if (mcrypt_generic_deinit(pm->td) < 0) {
|
||||
php_error_docref(NULL, E_WARNING, "Could not terminate encryption specifier");
|
||||
RETURN_FALSE
|
||||
RETURN_FALSE;
|
||||
}
|
||||
pm->init = 0;
|
||||
RETURN_TRUE
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -776,9 +776,9 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode)
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_algorithm_mode(pm->td) == 1) {
|
||||
RETURN_TRUE
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -790,9 +790,9 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm)
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_algorithm(pm->td) == 1) {
|
||||
RETURN_TRUE
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -804,9 +804,9 @@ PHP_FUNCTION(mcrypt_enc_is_block_mode)
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) {
|
||||
RETURN_TRUE
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_decrypt() function : error conditions
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : error conditions ***\n";
|
||||
|
||||
|
||||
//Test mcrypt_decrypt with one more than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_decrypt() function with more than expected no. of arguments --\n";
|
||||
$cipher = 'string_val';
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = 'string_val';
|
||||
$iv = 'string_val';
|
||||
$extra_arg = 10;
|
||||
var_dump( mcrypt_decrypt($cipher, $key, $data, $mode, $iv, $extra_arg) );
|
||||
|
||||
// Testing mcrypt_decrypt with one less than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_decrypt() function with less than expected no. of arguments --\n";
|
||||
$cipher = 'string_val';
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
var_dump( mcrypt_decrypt($cipher, $key, $data) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_decrypt() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_decrypt() function with more than expected no. of arguments --
|
||||
|
||||
Deprecated: Function mcrypt_decrypt() is deprecated in %s%emcrypt_decrypt_error.php on line 19
|
||||
|
||||
Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_decrypt() function with less than expected no. of arguments --
|
||||
|
||||
Deprecated: Function mcrypt_decrypt() is deprecated in %s%emcrypt_decrypt_error.php on line 26
|
||||
|
||||
Warning: mcrypt_decrypt() expects at least 4 parameters, 3 given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -1,255 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_decrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$iv = 'string_val';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for cipher
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_decrypt($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -1,255 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_decrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = 'string_val';
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$iv = '01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for key
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( bin2hex(mcrypt_decrypt($cipher, $value, $data, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -1,235 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_decrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = "string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$iv = '01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for data
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_decrypt($cipher, $key, $value, $mode, $iv)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "52833a00168e547f"
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "82011a0a93098a13"
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "e8b71c21b6acc162"
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "db3c458e975563a8"
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "6ee8764562f25913"
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d63b39fd5f65678e"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(32) "7712cc4828221be40672239d9c32e742"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(32) "caa892cb5d28b53c2b75b1e0799427c3"
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "99880c86884385d9"
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "82011a0a93098a13"
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "82011a0a93098a13"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(32) "46677e368bc07ef375bd580e0c4b2594"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
string(16) "d27689f6fd9700f4"
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -1,255 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_decrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$iv = '01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for mode
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_decrypt($cipher, $key, $data, $value, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -1,255 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_decrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_decrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_decrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = "string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
$data = 'string_val';
|
||||
$mode = MCRYPT_MODE_CBC;
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for iv
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump(bin2hex(mcrypt_decrypt($cipher, $key, $data, $mode, $value)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_decrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_decrypt() is deprecated, %s%emcrypt_decrypt_variation5.php(107)
|
||||
Error: 2 - mcrypt_decrypt() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
@@ -1,56 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_encrypt() function : error conditions
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : error conditions ***\n";
|
||||
|
||||
|
||||
//Test mcrypt_encrypt with one more than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_encrypt() function with more than expected no. of arguments --\n";
|
||||
$cipher = 'string_val';
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = 'string_val';
|
||||
$iv = 'string_val';
|
||||
$extra_arg = 10;
|
||||
var_dump( mcrypt_encrypt($cipher, $key, $data, $mode, $iv, $extra_arg) );
|
||||
|
||||
// Testing mcrypt_encrypt with one less than the expected number of arguments
|
||||
echo "\n-- Testing mcrypt_encrypt() function with less than expected no. of arguments --\n";
|
||||
$cipher = 'string_val';
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
var_dump( mcrypt_encrypt($cipher, $key, $data) );
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_encrypt() : error conditions ***
|
||||
|
||||
-- Testing mcrypt_encrypt() function with more than expected no. of arguments --
|
||||
|
||||
Deprecated: Function mcrypt_encrypt() is deprecated in %s%emcrypt_encrypt_error.php on line 19
|
||||
|
||||
Warning: mcrypt_encrypt() expects at most 5 parameters, 6 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing mcrypt_encrypt() function with less than expected no. of arguments --
|
||||
|
||||
Deprecated: Function mcrypt_encrypt() is deprecated in %s%emcrypt_encrypt_error.php on line 26
|
||||
|
||||
Warning: mcrypt_encrypt() expects at least 4 parameters, 3 given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_encrypt() function : usage variation - different types for cipher
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$iv = 'string_val';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for cipher
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_encrypt($value, $key, $data, $mode, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation1.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 1 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_encrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$data = 'string_val';
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$iv = '01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for key
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( bin2hex(mcrypt_encrypt($cipher, $value, $data, $mode, $iv) ));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Key of size %d not supported by this algorithm. Only keys of size 24 supported, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation2.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 2 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_encrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = "string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
$mode = MCRYPT_MODE_ECB;
|
||||
$iv = '01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for data
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( bin2hex(mcrypt_encrypt($cipher, $key, $value, $mode, $iv) ));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "51dc9cd9179b718b"
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "619c335f8c4f9cbf"
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "b1258d67ab73de00"
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "8eecf134443bd6b9"
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "34b5750a793baff5"
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "7a605f2aacc8a11d"
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(32) "74a0d7026ae586f476d4b17808851e86"
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(32) "bfb155997017986c01090afebd62c7ca"
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "cc60ac201164b6c7"
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "619c335f8c4f9cbf"
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "619c335f8c4f9cbf"
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(32) "749c3b4d16731d98370128754b7c930f"
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
string(16) "6ece228c41457539"
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation3.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 3 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_encrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = 'string_val';
|
||||
$data = 'string_val';
|
||||
$iv = '01234567';
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for mode
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( mcrypt_encrypt($cipher, $key, $data, $value, $iv) );
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
|
||||
NULL
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, object given, %s(%d)
|
||||
NULL
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
|
||||
bool(false)
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation4.php(107)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, resource given, %s(%d)
|
||||
NULL
|
||||
===DONE===
|
||||
@@ -1,257 +0,0 @@
|
||||
--TEST--
|
||||
Test mcrypt_encrypt() function : usage variation
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("mcrypt")) {
|
||||
print "skip - mcrypt extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string mcrypt_encrypt(string cipher, string key, string data, string mode, string iv)
|
||||
* Description: OFB crypt/decrypt data using key key with cipher cipher starting with iv
|
||||
* Source code: ext/mcrypt/mcrypt.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mcrypt_encrypt() : usage variation ***\n";
|
||||
|
||||
// Define error handler
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
// Initialise function arguments not being substituted (if any)
|
||||
$cipher = MCRYPT_TRIPLEDES;
|
||||
$key = "string_val\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
$data = 'string_val';
|
||||
//in php, it incorrectly reports problems with iv in ECB mode.
|
||||
$mode = MCRYPT_MODE_CBC;
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// define some classes
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
// heredoc string
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
// get a resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// add arrays
|
||||
$index_array = array (1, 2, 3);
|
||||
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||
|
||||
//array of values to iterate over
|
||||
$inputs = array(
|
||||
|
||||
// int data
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
|
||||
// float data
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
|
||||
// array data
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
|
||||
// null data
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
|
||||
// boolean data
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
|
||||
// empty data
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
|
||||
// object data
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
|
||||
// undefined data
|
||||
'undefined var' => @$undefined_var,
|
||||
|
||||
// unset data
|
||||
'unset var' => @$unset_var,
|
||||
|
||||
// resource variable
|
||||
'resource' => $fp
|
||||
);
|
||||
|
||||
// loop through each element of the array for iv
|
||||
|
||||
foreach($inputs as $valueType =>$value) {
|
||||
echo "\n--$valueType--\n";
|
||||
var_dump( bin2hex(mcrypt_encrypt($cipher, $key, $data, $mode, $value)));
|
||||
};
|
||||
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mcrypt_encrypt() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 1--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int 12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int -12345--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -10.5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float 12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float -12.3456789000e10--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--float .5--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--int indexed array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--associative array--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--nested arrays--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, array given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase NULL--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase null--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase true--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--lowercase false--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase TRUE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--uppercase FALSE--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string DQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--empty string SQ--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--instance of classWithoutToString--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, object given, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--undefined var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--unset var--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt(): Received initialization vector of size %d, but size 8 is required for this encryption mode, %s(%d)
|
||||
string(0) ""
|
||||
|
||||
--resource--
|
||||
Error: 8192 - Function mcrypt_encrypt() is deprecated, %s%emcrypt_encrypt_variation5.php(108)
|
||||
Error: 2 - mcrypt_encrypt() expects parameter 5 to be string, resource given, %s(%d)
|
||||
string(0) ""
|
||||
===DONE===
|
||||
|
||||
Reference in New Issue
Block a user