From db6f93b159c80f644c8521f40e8f1be8d2e93845 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 1 May 2021 12:22:07 +0200 Subject: [PATCH] Example of a better UTF8 to UTF16LE encoding in unit test. It allows digesting UTF8 encoded password candidates from the shell in passthrough mode --- tools/test_modules/m01000.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/test_modules/m01000.pm b/tools/test_modules/m01000.pm index 0a6a6b852..e380713bd 100644 --- a/tools/test_modules/m01000.pm +++ b/tools/test_modules/m01000.pm @@ -9,7 +9,7 @@ use strict; use warnings; use Digest::MD4 qw (md4_hex); -use Encode; +use Text::Iconv; sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } @@ -17,7 +17,9 @@ sub module_generate_hash { my $word = shift; - my $digest = md4_hex (encode ('UTF-16LE', $word)); + my $converter = Text::Iconv->new('utf8', 'UTF-16LE'); + + my $digest = md4_hex ($converter->convert ($word)); return $digest; }