WhirlpoolTest.pm.svn-base
上传用户:market2
上传日期:2018-11-18
资源大小:18786k
文件大小:1k
源码类别:

外挂编程

开发平台:

Windows_Unix

  1. package WhirlpoolTest;
  2. use strict;
  3. use Test::More;
  4. use Utils::Whirlpool qw(whirlpool whirlpool_hex);
  5. sub start {
  6. print "### Starting WhirlpoolTestn";
  7. WhirlpoolTest->new()->run();
  8. }
  9. ###################################
  10. sub new {
  11. my ($class) = @_;
  12. return bless {}, $class;
  13. }
  14. # Run the test.
  15. sub run {
  16. my ($self) = @_;
  17. testHash("", "19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A7" .
  18. "3E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3");
  19. testHash("The quick brown fox jumps over the lazy dog",
  20. "B97DE512E91E3828B40D2B0FDCE9CEB3C4A71F9BEA8D88E75C4FA854DF36725F" .
  21. "D2B52EB6544EDCACD6F8BEDDFEA403CB55AE31F03AD62A5EF54E42EE82C3FB35");
  22. testHash("The quick brown fox jumps over the lazy eog",
  23. "C27BA124205F72E6847F3E19834F925CC666D0974167AF915BB462420ED40CC5" .
  24. "0900D85A1F923219D832357750492D5C143011A76988344C2635E69D06F2D38C");
  25. }
  26. sub testHash {
  27. my ($data, $expectedHash) = @_;
  28. my $wp = new Utils::Whirlpool();
  29. $wp->add($data);
  30. my $hash = uc unpack("H*", $wp->finalize());
  31. is($hash, $expectedHash, ""$data"");
  32. $wp->init();
  33. $wp->add($data);
  34. $hash = uc unpack("H*", $wp->finalize());
  35. is($hash, $expectedHash, ""$data"");
  36. $hash = uc whirlpool_hex($data);
  37. is($hash, $expectedHash, ""$data"");
  38. }
  39. 1;