diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup
index 23d8a17ea2a55da0de25607044d1abd2003279d8..a511032fda27fabb7c90e681cc492ade10912637 100644
--- a/contrib/bin/fusiondirectory-setup
+++ b/contrib/bin/fusiondirectory-setup
@@ -44,6 +44,7 @@ use MIME::Base64;
 # used to generate {SSHA} password (for LDAP)
 use Digest::SHA;
 use Crypt::CBC;
+use Bytes::Random::Secure qw(random_string_from);
 
 # used to uncompress tar.gz
 use Archive::Extract;
@@ -229,9 +230,7 @@ sub get_random_string {
   my ($size) = @_;
   $size = 32 if !$size;
   my @chars = ("A".."Z", "a".."z", '.', '/', 0..9);
-  my $string;
-  $string .= $chars[rand @chars] for 1..$size;
-  return $string;
+  return random_string_from(join('', @chars), $size);
 }
 
 sub encrypt_passwords {