1--TEST-- 2openssl_encrypt() error tests 3--SKIPIF-- 4<?php if (!extension_loaded("openssl")) print "skip"; ?> 5--FILE-- 6<?php 7$data = "openssl_encrypt() tests"; 8$method = "AES-128-CBC"; 9$password = "openssl"; 10$iv = str_repeat("\0", openssl_cipher_iv_length($method)); 11$wrong = "wrong"; 12$object = new stdclass; 13$arr = array(1); 14 15// wrong parameters tests 16var_dump(openssl_encrypt($data, $wrong, $password)); 17var_dump(openssl_encrypt($object, $method, $password)); 18var_dump(openssl_encrypt($data, $object, $password)); 19var_dump(openssl_encrypt($data, $method, $object)); 20var_dump(openssl_encrypt($arr, $method, $object)); 21var_dump(openssl_encrypt($data, $arr, $object)); 22var_dump(openssl_encrypt($data, $method, $arr)); 23 24// padding of the key is disabled 25var_dump(openssl_encrypt($data, $method, $password, OPENSSL_DONT_ZERO_PAD_KEY, $iv)); 26?> 27--EXPECTF-- 28Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d 29bool(false) 30 31Warning: openssl_encrypt() expects parameter 1 to be string, object given in %s on line %d 32NULL 33 34Warning: openssl_encrypt() expects parameter 2 to be string, object given in %s on line %d 35NULL 36 37Warning: openssl_encrypt() expects parameter 3 to be string, object given in %s on line %d 38NULL 39 40Warning: openssl_encrypt() expects parameter 1 to be string, array given in %s on line %d 41NULL 42 43Warning: openssl_encrypt() expects parameter 2 to be string, array given in %s on line %d 44NULL 45 46Warning: openssl_encrypt() expects parameter 3 to be string, array given in %s on line %d 47NULL 48 49Warning: openssl_encrypt(): Key length cannot be set for the cipher method in %s on line %d 50bool(false) 51