Note that this could also just be documented doing:
dd if=/dev/urandom bs=1 count=10 2>/dev/null | base32
And using TOTP apps that can scan QR codes is much better UX anyway,
but its to trivial to bother deprecating it now and we'd still depend
on libmime-base32-perl, so really nothing gained in removing or
rewriting in shell..
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
use strict;
use warnings;
-use MIME::Base32; #libmime-base32-perl
-my $test;
-open(my $RND_FH, '<', "/dev/urandom");
-sysread($RND_FH, $test, 10) == 10 || die "read random data failed - $!\n";
-print MIME::Base32::encode_rfc3548($test) . "\n";
+use MIME::Base32; # libmime-base32-perl
+open(my $RND_FH, '<', "/dev/urandom") or die "Unable to open '/dev/urandom' - $!";
+sysread($RND_FH, my $random_data, 10) == 10 or die "read random data failed - $!\n";
+close $RND_FH or warn "Unable to close '/dev/urandom' - $!";
+
+print MIME::Base32::encode_rfc3548($random_data) . "\n";
+
+exit(0);