xref: /PHP-7.0/ext/mcrypt/tests/mcrypt_ecb.phpt (revision 7810659c)
1--TEST--
2mcrypt_ecb
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_ECB), MCRYPT_RAND);
12$enc_data = mcrypt_encrypt($cipher, $key, $secret, MCRYPT_MODE_ECB, $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_ECB, $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
18mcrypt_decrypt($cipher, $key, $enc_data, MCRYPT_MODE_ECB);
19
20--EXPECTF--
21PHP Testfest 2008
22