From 76ec0268a7ff8554c5e1c63cae1723b4538c7eea Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 02:20:03 +0200 Subject: [PATCH] Add unit test for -m 1410 -m 1420 -m ... -m 1440 -m 1710 -m 1720 -m 1730 -m 1740 -m 4300 -m 4400 -m 4500 -m 4520 -m 4700 --- tools/test_modules/m01410.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01420.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01430.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m01440.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m01710.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01720.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01730.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m01740.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m04300.pm | 42 +++++++++++++++++++++++++++++++++ tools/test_modules/m04400.pm | 43 ++++++++++++++++++++++++++++++++++ tools/test_modules/m04500.pm | 42 +++++++++++++++++++++++++++++++++ tools/test_modules/m04520.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m04700.pm | 43 ++++++++++++++++++++++++++++++++++ 13 files changed, 570 insertions(+) create mode 100644 tools/test_modules/m01410.pm create mode 100644 tools/test_modules/m01420.pm create mode 100644 tools/test_modules/m01430.pm create mode 100644 tools/test_modules/m01440.pm create mode 100644 tools/test_modules/m01710.pm create mode 100644 tools/test_modules/m01720.pm create mode 100644 tools/test_modules/m01730.pm create mode 100644 tools/test_modules/m01740.pm create mode 100644 tools/test_modules/m04300.pm create mode 100644 tools/test_modules/m04400.pm create mode 100644 tools/test_modules/m04500.pm create mode 100644 tools/test_modules/m04520.pm create mode 100644 tools/test_modules/m04700.pm diff --git a/tools/test_modules/m01410.pm b/tools/test_modules/m01410.pm new file mode 100644 index 000000000..83dd885a3 --- /dev/null +++ b/tools/test_modules/m01410.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); + +sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_hex ($word . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01420.pm b/tools/test_modules/m01420.pm new file mode 100644 index 000000000..a01cd310a --- /dev/null +++ b/tools/test_modules/m01420.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); + +sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_hex ($salt . $word); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01430.pm b/tools/test_modules/m01430.pm new file mode 100644 index 000000000..fc50531ce --- /dev/null +++ b/tools/test_modules/m01430.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); +use Encode; + +sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 55], [0, 27]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_hex (encode ("UTF-16LE", $word) . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01440.pm b/tools/test_modules/m01440.pm new file mode 100644 index 000000000..20d9fba07 --- /dev/null +++ b/tools/test_modules/m01440.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); +use Encode; + +sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 55], [0, 27]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_hex ($salt . encode ("UTF-16LE", $word)); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01710.pm b/tools/test_modules/m01710.pm new file mode 100644 index 000000000..2eea3aa98 --- /dev/null +++ b/tools/test_modules/m01710.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex); + +sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha512_hex ($word . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01720.pm b/tools/test_modules/m01720.pm new file mode 100644 index 000000000..4cf470ee6 --- /dev/null +++ b/tools/test_modules/m01720.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex); + +sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha512_hex ($salt . $word); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01730.pm b/tools/test_modules/m01730.pm new file mode 100644 index 000000000..7d69995b2 --- /dev/null +++ b/tools/test_modules/m01730.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex); +use Encode; + +sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 55], [0, 27]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha512_hex (encode ("UTF-16LE", $word) . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m01740.pm b/tools/test_modules/m01740.pm new file mode 100644 index 000000000..ec2f30eda --- /dev/null +++ b/tools/test_modules/m01740.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex); +use Encode; + +sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 55], [0, 27]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha512_hex ($salt . encode ("UTF-16LE", $word)); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04300.pm b/tools/test_modules/m04300.pm new file mode 100644 index 000000000..305aef2f5 --- /dev/null +++ b/tools/test_modules/m04300.pm @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = md5_hex (uc (md5_hex ($word))); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04400.pm b/tools/test_modules/m04400.pm new file mode 100644 index 000000000..9ea04ef6a --- /dev/null +++ b/tools/test_modules/m04400.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = md5_hex (sha1_hex ($word)); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04500.pm b/tools/test_modules/m04500.pm new file mode 100644 index 000000000..2eb160e99 --- /dev/null +++ b/tools/test_modules/m04500.pm @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = sha1_hex (sha1_hex ($word)); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04520.pm b/tools/test_modules/m04520.pm new file mode 100644 index 000000000..ba0294290 --- /dev/null +++ b/tools/test_modules/m04520.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 31], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha1_hex ($salt . sha1_hex ($word)); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04700.pm b/tools/test_modules/m04700.pm new file mode 100644 index 000000000..cf65f9771 --- /dev/null +++ b/tools/test_modules/m04700.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = sha1_hex (md5_hex ($word)); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1;