Source for file full.php

Documentation is available at full.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. //
  4. // +----------------------------------------------------------------------+
  5. // | PHP version 4.0 |
  6. // +----------------------------------------------------------------------+
  7. // | Copyright (c) 2004 The PHP Group |
  8. // +----------------------------------------------------------------------+
  9. // | This source file is subject to version 2.02 of the PHP license, |
  10. // | that is bundled with this package in the file LICENSE, and is |
  11. // | available at through the world-wide-web at |
  12. // | http://www.php.net/license/2_02.txt. |
  13. // | If you did not receive a copy of the PHP license and are unable to |
  14. // | obtain it through the world-wide-web, please send a note to |
  15. // | license@php.net so we can mail you a copy immediately. |
  16. // +----------------------------------------------------------------------+
  17. // | Authors: Jeroen Derks <jeroen@derks.it> |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: full.php,v 1.2 2004/10/04 19:51:56 jeroend Exp $
  21.  
  22.  
  23.  
  24. /**
  25. * Test a range of different characters and sizes.
  26. * Test a range of different characters and sizes.
  27. *
  28. * @package Crypt_Xtea_Test
  29. * @modulegroup Crypt_Xtea_Test
  30. * @module full
  31. * @access public
  32. *
  33. * @version $Revision: 1.2 $
  34. * @since 2004/Oct/04
  35. * @author Jeroen Derks <jeroen@derks.it>
  36. */
  37.  
  38. /** Crypt_Xtea class */
  39. 'Crypt/Xtea.php';
  40.  
  41. $obj = new Crypt_Xtea();
  42. $msg = $argv[1];
  43.  
  44. for ($i = 30; $i <= 34; ++$i)
  45. {
  46. $key = '';
  47. for ($n = $i; $n < $i + $i; ++$n)
  48. $key .= chr($n);
  49.  
  50. for ($j = 32; $j <= 64; ++$j)
  51. {
  52. $msg = '';
  53. for ($n = $j; $n < $j + $j; ++$n)
  54. $msg .= chr($n);
  55.  
  56. $result = $obj->encrypt($msg, $key);
  57.  
  58. $tmp = join('', unpack('H*', $result));
  59.  
  60. // output result
  61. printf("%3d.%3d: %s\n", $i, $j, $tmp);
  62.  
  63. $result = $obj->decrypt($result, $key);
  64. if ($result != $msg)
  65. die("ERROR: decryption failed\n");
  66. }
  67. }
  68. ?>

Documentation generated on Thu, 25 May 2006 15:31:26 +0200 by phpDocumentor 1.3.0RC3