File: random-sha512-oo.pl

package info (click to toggle)
libbytes-random-secure-perl 0.29-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 224 kB
  • sloc: perl: 415; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 487 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

use strict;
use warnings;
use Bytes::Random::Secure qw();
use Digest::SHA qw( sha512_base64 );

my $quantity = 128;

# Instantiate a random generator with a customized seed:

my $random = Bytes::Random::Secure->new( Bits => 64, NonBlocking => 1 );

# Get a string of 128 random bytes.
my $bytes    = $random->bytes($quantity);

# And just for fun, generate a base64 encoding of a sha2-512 digest of the
# random byte string.
my $digest   = sha512_base64( $bytes );

print "$digest\n";