diff options
Diffstat (limited to 'ext/openssl/tests/011.phpt')
-rw-r--r-- | ext/openssl/tests/011.phpt | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/openssl/tests/011.phpt b/ext/openssl/tests/011.phpt index 927360900..fdcc5e296 100644 --- a/ext/openssl/tests/011.phpt +++ b/ext/openssl/tests/011.phpt @@ -8,11 +8,16 @@ $data = "openssl_encrypt() and openssl_decrypt() tests"; $method = "AES-128-CBC"; $password = "openssl"; -$encrypted = openssl_encrypt($data, $method, $password); -$output = openssl_decrypt($encrypted, $method, $password); +$ivlen = openssl_cipher_iv_length($method); +$iv = ''; +srand(time() + ((microtime(true) * 1000000) % 1000000)); +while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255)); + +$encrypted = openssl_encrypt($data, $method, $password, false, $iv); +$output = openssl_decrypt($encrypted, $method, $password, false, $iv); var_dump($output); -$encrypted = openssl_encrypt($data, $method, $password, true); -$output = openssl_decrypt($encrypted, $method, $password, true); +$encrypted = openssl_encrypt($data, $method, $password, true, $iv); +$output = openssl_decrypt($encrypted, $method, $password, true, $iv); var_dump($output); ?> --EXPECT-- |