"Fossies" - the Fresh Open Source Software Archive

Member "Digest-SHA1-2.13/t/sha1.t" (6 Mar 2009, 1979 Bytes) of package /linux/privat/old/Digest-SHA1-2.13.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 print "1..13\n";
    2 
    3 use Digest::SHA1 qw(sha1 sha1_hex sha1_base64 sha1_transform);
    4 
    5 print "not " unless Digest::SHA1->new->add("abc")->hexdigest eq "a9993e364706816aba3e25717850c26c9cd0d89d";
    6 print "ok 1\n";
    7 
    8 print "not " unless sha1("abc") eq pack("H*", "a9993e364706816aba3e25717850c26c9cd0d89d");
    9 print "ok 2\n";
   10 
   11 print "not " unless sha1_hex("abc") eq "a9993e364706816aba3e25717850c26c9cd0d89d";
   12 print "ok 3\n";
   13 
   14 print "not " unless sha1_base64("abc") eq "qZk+NkcGgWq6PiVxeFDCbJzQ2J0";
   15 print "ok 4\n";
   16 
   17 # Test file checking from too...
   18 open(FILE, ">stest$$.txt") || die;
   19 binmode(FILE);
   20 for (1..512) {
   21     print FILE "This is line $_\n";
   22 }
   23 close(FILE);
   24 
   25 open(FILE, "stest$$.txt") || die;
   26 $digest = Digest::SHA1->new->addfile(*FILE)->b64digest;
   27 print "$digest\nnot " unless $digest eq "1ZuIK/sQeBwqh+dIACqpnoRQUE4";
   28 print "ok 5\n";
   29 close(FILE);
   30 
   31 unlink("stest$$.txt");
   32 
   33 
   34 print "not " unless sha1_transform(pack('H*', 'dc71a8092d4b1b7b98101d58698d9d1cc48225bb')) 
   35 	eq pack('H*', '2e4c75ad39160f52614d122e6c7ec80446f68567');
   36 print "ok 6\n";
   37 
   38 print "not " unless sha1_transform(pack('H*', '0abe1db666612acdf95d2f86d60c65210b78ab23')) 
   39 	eq pack('H*', '7c1c2aabca822912f3016299b160035787477b48');
   40 print "ok 7\n";
   41 
   42 print "not " unless sha1_transform(pack('H*', '86da486230e353e0ec5e9220876c687892c0266c')) 
   43 	eq pack('H*', '1da304aec652c21d4f54642434705c91aeaf9abe');
   44 print "ok 8\n";
   45 
   46 $digest = Digest::SHA1->new;
   47 print "not " unless $digest->hexdigest eq "da39a3ee5e6b4b0d3255bfef95601890afd80709";
   48 print "ok 9\n";
   49 
   50 print "not " unless $digest->clone->hexdigest eq "da39a3ee5e6b4b0d3255bfef95601890afd80709";
   51 print "ok 10\n";
   52 
   53 $digest->add("abc");
   54 print "not " unless $digest->clone->hexdigest eq "a9993e364706816aba3e25717850c26c9cd0d89d";
   55 print "ok 11\n";
   56 
   57 $digest->add("d");
   58 print "not " unless $digest->hexdigest eq "81fe8bfe87576c3ecb22426f8e57847382917acf";
   59 print "ok 12\n";
   60 
   61 print "not " unless $digest->hexdigest eq "da39a3ee5e6b4b0d3255bfef95601890afd80709";
   62 print "ok 13\n";