6 $MODULE = ($ENV{PERL_CORE} || -e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl";
7 eval "require $MODULE" || die $@;
8 $MODULE->import(qw(hmac_sha1_hex));
12 if ($ENV{PERL_CORE}) {
18 my @data = map { "Sample #$_" } (1 .. 4);
21 "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a",
22 "0922d3405faa3d194f82a45830737d5cc6c75d24",
23 "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa",
24 "9ea886efe268dbecce420c7524df32e0751a2a26"
27 my @keys = ("", "", "", "");
29 for (0x00 .. 0x00+63) { $keys[0] .= chr($_) }
30 for (0x30 .. 0x30+19) { $keys[1] .= chr($_) }
31 for (0x50 .. 0x50+99) { $keys[2] .= chr($_) }
32 for (0x70 .. 0x70+48) { $keys[3] .= chr($_) }
34 my $numtests = scalar @data;
35 print "1..$numtests\n";
39 print "not " unless hmac_sha1_hex(shift @data, shift @keys)
41 print "ok ", $testnum++, "\n";