Documentation is available at xtea.php
- <?php
- //
- // xtea.php
- //
- // $Header: /cvs/ext/pear/Crypt_Xtea/tests/Attic/xtea.php,v 1.2 2004/10/04 18:54:19 jeroend Exp $
- //
- /**
- * @package Crypt_Xtea_Test
- * @module xtea
- * @access public
- *
- * @version $Revision: 1.2 $
- * @since 2002/Sep/30
- * @author Jeroen Derks <jeroen@derks.it>
- */
- /** Crypt_Xtea class */
- '../Xtea.php';
- $flag_decrypt = false; // do encryption by default
- $msg = ''; // initialize message to encrypt/decrypt
- $key = ''; // initialize key to use
- $prog = basename($_SERVER['argv'][0]); // program name
- $argc = $_SERVER['argc']; // number of command line arguments
- $argv = $_SERVER['argv']; // command line arguments array
- // process command line flags
- while (1 < $argc && '-' == $argv[1]{0})
- {
- $argc--;
- $arg = $argv[1];
- array_shift($argv);
- if ('--' == $arg)
- break;
- $arg = substr($arg, 1);
- while (0 < strlen($arg))
- {
- switch ($arg{0})
- {
- case 'd': $flag_decrypt = true; break;
- case 'e': $flag_decrypt = false; break;
- }
- $arg = substr($arg, 1);
- }
- }
- // check required parameters
- if (2 >= $argc)
- {
- echo "usage: $prog [-de] key msg [ msg ... ]\n" .
- "\t-d\tdecrypt message\n" .
- "\t-e\tencrypt message (default action)\n";
- exit(1);
- }
- // get key
- $key = $argv[1];
- $argc--;
- array_shift($argv);
- // get messages
- while (1 < $argc)
- {
- $obj = new Crypt_Xtea();
- $msg = $argv[1];
- if ($flag_decrypt)
- {
- $binmsg = pack('H' . strlen($msg), $msg);
- $result = $obj->decrypt($binmsg, $key);
- }
- else
- {
- $binmsg = $obj->encrypt($msg, $key);
- $result = join('', unpack('H*', $binmsg));
- }
- // output result
- echo $result;
- // get next message
- $argc--;
- $arg = array_shift($argv);
- $msg = '';
- }
- ?>
Documentation generated on Thu, 25 May 2006 15:31:27 +0200 by phpDocumentor 1.3.0RC3