From a677920fd81ab7a0306e291d191c3bc3e0b7a1cd Mon Sep 17 00:00:00 2001 From: jsteube Date: Sun, 17 Feb 2019 15:44:27 +0100 Subject: [PATCH] Add -m 8400 unit test --- tools/test_modules/m08400.pm | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tools/test_modules/m08400.pm diff --git a/tools/test_modules/m08400.pm b/tools/test_modules/m08400.pm new file mode 100644 index 000000000..f25431138 --- /dev/null +++ b/tools/test_modules/m08400.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], [40, 40], [0, 55], [40, 40], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $hash_buf = sha1_hex ($salt . sha1_hex ($salt . sha1_hex ($word))); + + my $hash = sprintf ("%s:%s", $hash_buf, $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;