#!/usr/bin/perl use strict; use warnings; use Digest (); use Math::BigInt (); sub digest_mix {    my ($random1) = @_;    my $ctx = Digest->new("SHA-256");    for my $i (0 .. 31) {        my $r = $random1->copy;        my $c = $r->band(0xff);        $ctx->add($c);        $random1->brsft(8);    }    return $ctx->hexdigest; } {    my $_rand = Math::BigInt->new("0x" . unpack("H*", pack("L", time)));    sub srandom {        $_rand = Math::BigInt->new(shift) if @_;        return $_rand;    }    sub random {        $_rand = Math::BigInt->new("0x" . digest_mix($_rand));        return $_rand->bstr;    } }