BEGIN { $| = 1; print "1..83\n"; } use Crypt::Spritz; my $n = 0; my $c1 = new Crypt::Spritz; for ( [ABC => "779a8e01f9e9cbc0", "028fa2b48b934a1862b86910513a47677c1c2d95ec3e7570786f1c328bbd4a47"], [spam => "f0609a1df143cebf", "acbba0813f300d3a30410d14657421c15b55e3a14e3236b03989e797c7af4789"], [arcfour => "1afa8b5ee337dbc7", "ff8cf268094c87b95f74ce6fee9d3003a5f9fe6944653cd50e66bf189c63f699"], ) { my ($a, $r, $h) = @$_; $c1->absorb ($a); my $s = unpack "H*", $c1->squeeze (0.5 * length $r); print $s eq $r ? "" : "not ", "ok ", ++$n, " # AS1 $a => $s (= $r)\n"; $c1->init; my $c2 = new Crypt::Spritz; $c2->absorb ($_) for split //, $a; my $s = unpack "H*", join "", map $c2->squeeze (1), 1 .. 0.5 * length $r; print $s eq $r ? "" : "not ", "ok ", ++$n, " # AS2 $a => $s (= $r)\n"; my $h1 = new Crypt::Spritz::Hash; $h1->add ($a); $h1 = unpack "H*", $h1->finish (32); print $h eq $h1 ? "" : "not ", "ok ", ++$n, " # H $a => $h1 (= $h)\n"; my $cx = new Crypt::Spritz::Cipher::XOR $a; $cx = unpack "H*", $cx->crypt ("12345678") ^ "12345678"; print $r eq $cx ? "" : "not ", "ok ", ++$n, " # CX $a => $cx (= $r)\n"; } print "99 ok\n";