ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Crypt-Spritz/t/01_spritz.t
(Generate patch)

Comparing Crypt-Spritz/t/01_spritz.t (file contents):
Revision 1.1 by root, Sat Jan 10 03:15:59 2015 UTC vs.
Revision 1.2 by root, Sat Jan 10 04:14:17 2015 UTC

1BEGIN { $| = 1; print "1..83\n"; } 1BEGIN { $| = 1; print "1..83\n"; }
2 2
3use Crypt::Spritz; 3use Crypt::Spritz;
4 4
5my $n = 0; 5my $n = 0;
6
6my $c1 = new Crypt::Spritz; 7my $c1 = new Crypt::Spritz;
7 8
8for ( 9for (
9 # emacs!spritz! 10 [ABC => "779a8e01f9e9cbc0", "028fa2b48b934a1862b86910513a47677c1c2d95ec3e7570786f1c328bbd4a47"],
10 [ABC => "779a8e01f9e9cbc0", "028a8bfb39d4c846b302f9c1b13b05c6c578077485b528d2faab09e388a9a091"], 11 [spam => "f0609a1df143cebf", "acbba0813f300d3a30410d14657421c15b55e3a14e3236b03989e797c7af4789"],
11 [spam => "f0609a1df143cebf", "acb7908ee9002d2ba0adb3ff46c675f84b0aa8ff7e3aec3807626b09b5516368"], 12 [arcfour => "1afa8b5ee337dbc7", "ff8cf268094c87b95f74ce6fee9d3003a5f9fe6944653cd50e66bf189c63f699"],
12 [arcfour => "1afa8b5ee337dbc7", "ff1cbe5195b2dbb6398995603a125f56780b73821cd35dee5454969c3a02f753"],
13) { 13) {
14 my ($a, $r, $h) = @$_; 14 my ($a, $r, $h) = @$_;
15 15
16 $c1->absorb ($a); 16 $c1->absorb ($a);
17 my $s = unpack "H*", $c1->squeeze (0.5 * length $r); 17 my $s = unpack "H*", $c1->squeeze (0.5 * length $r);
23 23
24 $c2->absorb ($_) for split //, $a; 24 $c2->absorb ($_) for split //, $a;
25 my $s = unpack "H*", join "", map $c2->squeeze (1), 1 .. 0.5 * length $r; 25 my $s = unpack "H*", join "", map $c2->squeeze (1), 1 .. 0.5 * length $r;
26 print $s eq $r ? "" : "not ", "ok ", ++$n, " # AS2 $a => $s (= $r)\n"; 26 print $s eq $r ? "" : "not ", "ok ", ++$n, " # AS2 $a => $s (= $r)\n";
27 27
28 my $h1 = new Crypt::Spritz::HASH; 28 my $h1 = new Crypt::Spritz::Hash;
29 $h1->add ($a); 29 $h1->add ($a);
30 $h1 = unpack "H*", $h1->finish (32); 30 $h1 = unpack "H*", $h1->finish (32);
31 31
32 print $h eq $h1 ? "" : "not ", "ok ", ++$n, " # H $a => $h1 (= $h)\n"; 32 print $h eq $h1 ? "" : "not ", "ok ", ++$n, " # H $a => $h1 (= $h)\n";
33
34 my $cx = new Crypt::Spritz::Cipher::XOR $a;
35 $cx = unpack "H*", $cx->crypt ("12345678") ^ "12345678";
36
37 print $r eq $cx ? "" : "not ", "ok ", ++$n, " # CX $a => $cx (= $r)\n";
33} 38}
34 39
40print "99 ok\n";
35 41
42

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines