Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (57 sloc) 2.176 kb
dbed6d70 »
2007-03-27 RC2
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$
21
22 /**
23 * Test a range of different characters and sizes.
24 * Test a range of different characters and sizes.
25 *
26 * @package Crypt_Xtea_Test
27 * @modulegroup Crypt_Xtea_Test
28 * @module full
29 * @access public
30 *
31 * @version $Revision$
32 * @since 2004/Oct/04
33 * @author Jeroen Derks <jeroen@derks.it>
34 */
35
36 /** Crypt_Xtea class */
37 require_once 'Crypt/Xtea.php';
38
39 $obj = new Crypt_Xtea();
40 $msg = $argv[1];
41
42 for ($i = 30; $i <= 34; ++$i)
43 {
44 $key = '';
45 for ($n = $i; $n < $i + $i; ++$n)
46 $key .= chr($n);
47
48 for ($j = 32; $j <= 64; ++$j)
49 {
50 $msg = '';
51 for ($n = $j; $n < $j + $j; ++$n)
52 $msg .= chr($n);
53
54 $result = $obj->encrypt($msg, $key);
55
56 $tmp = join('', unpack('H*', $result));
57
58 // output result
59 printf("%3d.%3d: %s\n", $i, $j, $tmp);
60
61 $result = $obj->decrypt($result, $key);
62 if ($result != $msg)
63 die("ERROR: decryption failed\n");
64 }
65 }
66 ?>
Something went wrong with that request. Please try again.