Commit | Line | Data |
747da336 |
1 | use strict; |
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(sha256_hex)); |
9 | } |
10 | |
11 | BEGIN { |
12 | if ($ENV{PERL_CORE}) { |
13 | chdir 't' if -d 't'; |
14 | @INC = '../lib'; |
15 | } |
16 | } |
17 | |
18 | my @vecs = map { eval } <DATA>; |
19 | $#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; |
20 | |
21 | my $numtests = scalar(@vecs) / 2; |
22 | print "1..$numtests\n"; |
23 | |
24 | for (1 .. $numtests) { |
25 | my $data = shift @vecs; |
26 | my $digest = shift @vecs; |
27 | print "not " unless sha256_hex($data) eq $digest; |
28 | print "ok ", $_, "\n"; |
29 | } |
30 | |
31 | __DATA__ |
32 | "abc" |
33 | "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" |
34 | "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" |
35 | "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" |
36 | "a" x 1000000 |
37 | "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" |