xref: /PHP-7.1/ext/mcrypt/tests/mcrypt_cbc.phpt (revision dadef203)
1--TEST--
2mcrypt_cbc
3--SKIPIF--
4<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
5--FILE--
6<?php
7$key      = "0123456789012345";
8$secret   = "PHP Testfest 2008";
9$cipher   = MCRYPT_RIJNDAEL_128;
10
11$iv       = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_CBC), MCRYPT_RAND);
12$enc_data = mcrypt_encrypt($cipher, $key, $secret, MCRYPT_MODE_CBC, $iv);
13
14// we have to trim as AES rounds the blocks and decrypt doesnt detect that
15echo trim(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CBC, $iv)) . "\n";
16
17// a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
18var_dump(mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_CBC));
19
20?>
21--EXPECTF--
22Deprecated: Function mcrypt_get_iv_size() is deprecated in %s%emcrypt_cbc.php on line 6
23
24Deprecated: Function mcrypt_create_iv() is deprecated in %s%emcrypt_cbc.php on line 6
25
26Deprecated: Function mcrypt_encrypt() is deprecated in %s%emcrypt_cbc.php on line 7
27
28Deprecated: Function mcrypt_decrypt() is deprecated in %s%emcrypt_cbc.php on line 10
29PHP Testfest 2008
30
31Deprecated: Function mcrypt_decrypt() is deprecated in %s%emcrypt_cbc.php on line 13
32
33Warning: mcrypt_decrypt(): Encryption mode requires an initialization vector of size 16 in %s on line %d
34bool(false)
35