diff --git a/tools/test.pl b/tools/test.pl
index f8bf28bbc..d1838956b 100755
--- a/tools/test.pl
+++ b/tools/test.pl
@@ -2298,15 +2298,17 @@ sub verify
 
       my @data = split ('\$', $hash_in);
 
-      next unless scalar @data == 2;
+      next unless scalar @data == 3;
 
       shift @data;
 
       my $signature = shift @data;
       my $digest    = shift @data;
 
-      next unless ($signature eq '$axcrypt_sha1');
-      next unless (length ($digest) == 32 || length ($digest) == 40);
+      my $param = length ($digest);
+
+      next unless ($signature eq 'axcrypt_sha1');
+      next unless (($param == 32) || ($param == 40));
 
       next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in})));
     }
@@ -2695,6 +2697,14 @@ sub verify
 
       return unless (substr ($line, 0, $len) eq $hash_out);
     }
+    elsif ($mode == 10200)
+    {
+      $hash_out = gen_hash ($mode, $word, $salt, $param);
+
+      $len = length $hash_out;
+
+      return unless (substr ($line, 0, $len) eq $hash_out);
+    }
     elsif ($mode == 10400)
     {
       $hash_out = gen_hash ($mode, $word, $salt, 0, $param, $param2, $param3);
@@ -2857,6 +2867,14 @@ sub verify
 
       return unless (substr ($line, 0, $len) eq $hash_out);
     }
+    elsif ($mode == 13300)
+    {
+      $hash_out = gen_hash ($mode, $word, $salt, $iter, $param);
+
+      $len = length $hash_out;
+
+      return unless (substr ($line, 0, $len) eq $hash_out);
+    }
     elsif ($mode == 13400)
     {
       $hash_out = gen_hash ($mode, $word, $salt, $iter, $param);
@@ -4468,9 +4486,7 @@ sub gen_hash
   {
     $hash_buf = sha1 ($word_buf);
 
-    my $base64_buf = encode_base64 ($hash_buf);
-
-    chomp ($base64_buf);
+    my $base64_buf = encode_base64 ($hash_buf, "");
 
     $tmp_hash = sprintf ("{SHA}%s", $base64_buf);
   }
@@ -4484,9 +4500,7 @@ sub gen_hash
   {
     $hash_buf = sha1 ($word_buf . $salt_buf);
 
-    my $base64_buf = encode_base64 ($hash_buf . $salt_buf);
-
-    chomp ($base64_buf);
+    my $base64_buf = encode_base64 ($hash_buf . $salt_buf, "");
 
     $tmp_hash = sprintf ("{SSHA}%s", $base64_buf);
   }
@@ -4554,8 +4568,7 @@ sub gen_hash
   {
     $hash_buf = sha1 (encode ("UTF-16LE", $word_buf));
 
-    $hash_buf = encode_base64 ($hash_buf);
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($hash_buf, "");
 
     $tmp_hash = sprintf ("%s", $hash_buf);
   }
@@ -4569,11 +4582,8 @@ sub gen_hash
   {
     $hash_buf = sha1 ($salt_buf . encode ("UTF-16LE", $word_buf));
 
-    my $base64_salt_buf = encode_base64 ($salt_buf);
-
-    chomp ($base64_salt_buf);
-
-    my $base64_hash_buf = encode_base64 ($hash_buf);
+    my $base64_salt_buf = encode_base64 ($salt_buf, "");
+    my $base64_hash_buf = encode_base64 ($hash_buf, "");
 
     $base64_hash_buf = substr ($base64_hash_buf, 0, 27);
 
@@ -4683,9 +4693,7 @@ sub gen_hash
   {
     $hash_buf = sha256_hex ($word_buf . $salt_buf);
 
-    my $base64_buf = encode_base64 (pack ("H*", $hash_buf) . $salt_buf);
-
-    $base64_buf =~ s/[ \n]//g;
+    my $base64_buf = encode_base64 (pack ("H*", $hash_buf) . $salt_buf, "");
 
     $tmp_hash = sprintf ("{SSHA256}%s", $base64_buf);
   }
@@ -4711,13 +4719,8 @@ sub gen_hash
   {
     $hash_buf = sha256 ($salt_buf . encode ("UTF-16LE", $word_buf));
 
-    my $base64_salt_buf = encode_base64 ($salt_buf);
-
-    chomp ($base64_salt_buf);
-
-    my $base64_hash_buf = encode_base64 ($hash_buf);
-
-    chomp ($base64_hash_buf);
+    my $base64_salt_buf = encode_base64 ($salt_buf, "");
+    my $base64_hash_buf = encode_base64 ($hash_buf, "");
 
     $base64_hash_buf = substr ($base64_hash_buf, 0, 43);
 
@@ -4773,9 +4776,7 @@ sub gen_hash
   {
     $hash_buf = sha512_hex ($word_buf . $salt_buf);
 
-    my $base64_buf = encode_base64 (pack ("H*", $hash_buf) . $salt_buf);
-
-    $base64_buf =~ s/[ \n]//g;
+    my $base64_buf = encode_base64 (pack ("H*", $hash_buf) . $salt_buf, "");
 
     $tmp_hash = sprintf ("{SSHA512}%s", $base64_buf);
   }
@@ -4998,7 +4999,7 @@ sub gen_hash
     $hash_buf .= "\x00" x (256 - $eapol_len);
 
     # base64 encode the output
-    $tmp_hash = encode_base64 ($hash_buf, '');
+    $tmp_hash = encode_base64 ($hash_buf, "");
   }
   elsif ($mode == 2600)
   {
@@ -5307,7 +5308,7 @@ sub gen_hash
   {
     $hash_buf = sha256 ($word_buf);
 
-    my $base64_buf = encode_base64 ($hash_buf);
+    my $base64_buf = encode_base64 ($hash_buf, "");
 
     $tmp_hash = "";
 
@@ -5492,8 +5493,7 @@ sub gen_hash
 
     my $hash = sha1 ($salt_bin . $word_buf . $FORTIGATE_MAGIC);
 
-    $hash = encode_base64 ($salt_bin . $hash);
-    $hash =~ s/[\r\n]//g;
+    $hash = encode_base64 ($salt_bin . $hash, "");
 
     $tmp_hash = sprintf ("%s%s", $FORTIGATE_SIGNATURE, $hash);
   }
@@ -5928,7 +5928,7 @@ sub gen_hash
       iterations => $iterations
     );
 
-    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf));
+    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf), "");
 
     $tmp_hash = "";
 
@@ -6284,8 +6284,7 @@ sub gen_hash
       iterations => $iterations
     );
 
-    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf));
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf), "");
 
     $tmp_hash = sprintf ("pbkdf2_sha256\$%i\$%s\$%s", $iterations, $salt_buf, $hash_buf);
   }
@@ -6305,8 +6304,7 @@ sub gen_hash
   }
   elsif ($mode == 10200)
   {
-    my $challengeb64 = encode_base64 ($salt_buf);
-    $challengeb64 =~ s/[\r\n]//g;
+    my $challengeb64 = encode_base64 ($salt_buf, "");
 
     my $username;
 
@@ -6321,8 +6319,7 @@ sub gen_hash
 
     $hash_buf = hmac_hex ($salt_buf, $word_buf, \&md5);
 
-    my $responseb64 = encode_base64 ($username . " " . $hash_buf);
-    $responseb64 =~ s/[\r\n]//g;
+    my $responseb64 = encode_base64 ($username . " " . $hash_buf, "");
 
     $tmp_hash = sprintf ('$cram_md5$%s$%s', $challengeb64, $responseb64);
   }
@@ -6342,8 +6339,7 @@ sub gen_hash
       $hash_buf = sha1 ($word_buf . $hash_buf);
     }
 
-    $hash_buf = encode_base64 ($hash_buf . $salt_buf);
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($hash_buf . $salt_buf, "");
 
     $tmp_hash = sprintf ("{x-issha, %i}%s", $iterations, $hash_buf);
   }
@@ -6610,12 +6606,9 @@ sub gen_hash
       output_len => $out_len
     );
 
-    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf));
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf), "");
 
-    my $base64_salt_buf = encode_base64 ($salt_buf);
-
-    chomp ($base64_salt_buf);
+    my $base64_salt_buf = encode_base64 ($salt_buf, "");
 
     $tmp_hash = sprintf ("sha256:%i:%s:%s", $iterations, $base64_salt_buf, $hash_buf);
   }
@@ -6953,11 +6946,8 @@ sub gen_hash
 
     # sanitize $word_buf and $salt_buf:
 
-    my $word_buf_base64 = encode_base64 ($word_buf);
-    $word_buf_base64 =~ s/[\r\n]//g;
-
-    my $salt_buf_base64 = encode_base64 ($salt_buf);
-    $salt_buf_base64 =~ s/[\r\n]//g;
+    my $word_buf_base64 = encode_base64 ($word_buf, "");
+    my $salt_buf_base64 = encode_base64 ($salt_buf, "");
 
     # sanitize lenghs
 
@@ -7035,12 +7025,9 @@ END_CODE
 
     $hash_buf = pack ("H*", $php_output);
 
-    $hash_buf = encode_base64 ($hash_buf);
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($hash_buf, "");
 
-    my $base64_salt_buf = encode_base64 ($salt_buf);
-
-    chomp ($base64_salt_buf);
+    my $base64_salt_buf = encode_base64 ($salt_buf, "");
 
     $tmp_hash = sprintf ("md5:%i:%s:%s", $iterations, $base64_salt_buf, $hash_buf);
   }
@@ -7067,12 +7054,9 @@ END_CODE
       output_len => $out_len
     );
 
-    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf));
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf), "");
 
-    my $base64_salt_buf = encode_base64 ($salt_buf);
-
-    chomp ($base64_salt_buf);
+    my $base64_salt_buf = encode_base64 ($salt_buf, "");
 
     $tmp_hash = sprintf ("sha1:%i:%s:%s", $iterations, $base64_salt_buf, $hash_buf);
   }
@@ -7085,8 +7069,7 @@ END_CODE
       output_len => 32
     );
 
-    my $base64_buf = encode_base64 ($salt_buf . $pbkdf2->PBKDF2 ($salt_buf, $word_buf));
-    $base64_buf =~ s/[\r\n]//g;
+    my $base64_buf = encode_base64 ($salt_buf . $pbkdf2->PBKDF2 ($salt_buf, $word_buf), "");
 
     $tmp_hash = sprintf ("{PKCS5S2}%s", $base64_buf);
   }
@@ -7113,12 +7096,9 @@ END_CODE
       output_len => $out_len
     );
 
-    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf));
-    $hash_buf =~ s/[\r\n]//g;
+    $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt_buf, $word_buf), "");
 
-    my $base64_salt_buf = encode_base64 ($salt_buf);
-
-    chomp ($base64_salt_buf);
+    my $base64_salt_buf = encode_base64 ($salt_buf, "");
 
     $tmp_hash = sprintf ("sha512:%i:%s:%s", $iterations, $base64_salt_buf, $hash_buf);
   }