mcrypt_cfb.phpt 1014 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. mcrypt_cfb
  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. $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_CFB), MCRYPT_RAND);
  11. $enc_data = mcrypt_cfb($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
  12. // we have to trim as AES rounds the blocks and decrypt doesnt detect that
  13. echo trim(mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
  14. // a warning must be issued if we don't use a IV on a AES cipher, that usually requires an IV
  15. var_dump(mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT));
  16. --EXPECTF--
  17. Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d
  18. Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d
  19. PHP Testfest 2008
  20. Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d
  21. Warning: mcrypt_cfb(): Encryption mode requires an initialization vector of size 16 in %s on line %d
  22. bool(false)