Commit | Line | Data |
6bc89f92 |
1 | use strict; |
747da336 |
2 | |
3 | my $MODULE; |
4 | |
5 | BEGIN { |
72aa8e26 |
6 | $MODULE = ($ENV{PERL_CORE} || -e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; |
747da336 |
7 | eval "require $MODULE" || die $@; |
8 | $MODULE->import(qw(sha512_hex)); |
9 | } |
6bc89f92 |
10 | |
41c686de |
11 | BEGIN { |
77d2a621 |
12 | if ($ENV{PERL_CORE}) { |
13 | chdir 't' if -d 't'; |
14 | @INC = '../lib'; |
15 | } |
41c686de |
16 | } |
17 | |
747da336 |
18 | my @vecs = map { eval } <DATA>; |
19 | $#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; |
6bc89f92 |
20 | |
747da336 |
21 | my $numtests = scalar(@vecs) / 2; |
22 | print "1..$numtests\n"; |
6bc89f92 |
23 | |
24 | my $skip = sha512_hex("") ? 0 : 1; |
25 | |
747da336 |
26 | for (1 .. $numtests) { |
27 | my $data = shift @vecs; |
28 | my $digest = shift @vecs; |
29 | unless ($skip) { |
30 | print "not " unless sha512_hex($data) eq $digest; |
31 | } |
32 | print "ok ", $_, $skip ? " # skip: no 64 bit" : "", "\n"; |
6bc89f92 |
33 | } |
747da336 |
34 | |
35 | __DATA__ |
36 | "abc" |
37 | "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" |
38 | "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" |
39 | "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" |
40 | "a" x 1000000 |
41 | "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" |